コード例 #1
0
void ConnectionManager::HandleResponse(void)
{
    switch(actionCounter)
    {
    case ERedirect:
        Redirection();
        break;

    case EDataRequest:
        HandleBannerData();
        break;
    case EContinueDataRequest:
        HandleBannerData(EContinue);
        break;
    }
}
コード例 #2
0
ファイル: Ex2.c プロジェクト: gitter-badger/OperatingSystem
int main(){
             			// choice is the first argument
   		char *path[100],*path_temp;
   		char *args_temp;
   		char history[1000][1000];
   		char *newpath;
   		bool historyflag=false;
   		char paths[100];
   	 	
   	 	int ttoo = 1;
   		int history_index=0,numbering_index=0;
   		DIR * dir[100];
   		int f=0;
   		int args_len =0, path_len=0;
   		path_temp=getenv("MYPATH");
		path_temp=strtok(path_temp,":");
		while(path_temp!=NULL)  									// tokenizing paths ie different paths separated by : 
		{
		   	path[path_len]=path_temp;
		   	path_len++;
		   	//printf("%s\n",path_temp );
		   	path_temp = strtok(NULL,":");

		}
	    while(1){
			char *choice=malloc(1000);
			char *args[100];
	    	int flag = 0;
   	 		int flag_to=0;
   	 																			//infinite while loop starting
			args_len = 0;
			int pipe_flag2=0;
			printf(">>>>>>>");
			int s;
			//printf("%s before\n",choice);
			fgets(choice,1000,stdin);
			choice=trimwhitespace(choice);
			if(choice[0]=='\0'){
				continue;
			}
			if(choice[0]=='!' & strlen(choice)==1){
				continue;
			}
			if(choice[0]=='!'){
				char * temp;
				//printf("%s\n", choice);
				temp=strndup(choice+1,strlen(choice)-1);
				strcpy(choice,temp);
				//printf("%s\n", choice);
				historyChecking(history,&history_index,choice, historyflag);
			}
			else{
				historyChecking(history,&history_index,choice, historyflag);
			}
			PreArgsProcessing(args,paths,&args_len,choice,args_temp);
			struct dirent * file;
			//================================================================================================================
																				
			if(strncmp(args[0],"history",7)==0){										// history printing 
				
				historyPrinting(history,history_index, numbering_index,historyflag); // when you want to print history
				continue;	
			}
			//===============================================================================================================
			if(strncmp(args[0],"exit",4)==0 || strncmp(args[0],"quit",4)==0){    // exit or bye
				printf("bye\n");
				exit(0);
			}
			if(strncmp(args[args_len-2],"&",1)==0){		
    			//printf( "found %s\n", args[args_len-2] );
    												//Background command 
				BackgroundProcesses(args,paths,args_len);
				flag=1;
				continue;	
			}
															// checking for paramater to verify the arguments                     
		 	else if(strncmp(args[0],"cd",2)==0){							// cd command 
					cdProcessing(args,paths,args_len);
					continue;	
			}
			// checking for various commands
			for(int i=0;i<args_len-1;i++)
			{
				if(strncmp(args[i],"!",1)==0){		
	    			//printf( "found %s\n", args[0] );									// Exclamation command 
					//historyChecking(history,&history_index,choice, historyflag);
					runExclamationCommand(args,paths,args_len,history,choice,args_temp,&history_index);
					flag=1;
					break;	
				}
				if(strncmp(args[i],"<",1)==0 || strncmp(args[i],">",1)==0 || strncmp(args[i],">>",2)==0){  // redirection
					Redirection(args,paths,args_len,choice,args_temp,&flag_to);
					flag=1;
					break;
				}
				if(strncmp(args[i],"|",1)==0){		
					//printf( "found %s\n", args[1] );									// pipe command 
					
					IPCPipes(args,paths,&args_len,path_len,path);
					flag=1;
					pipe_flag2=1;
					break;
				}
			}
			
			if(flag & !flag_to & !pipe_flag2){
				// the commands left at the end will be executed
				newpath=checkingParamter(args,paths,args_len,path,dir,path_len,file,newpath);
				//printf("chetan%s\n", newpath);
				if(newpath==NULL){
				}
				else {
					for(int i=0;i<args_len;i++){
						//printf("anand sahu%s\n",args[i] );
					}
					forkMethod(args,newpath,args_len);
				}	
			}
			if(!flag & !flag_to & !pipe_flag2){
				// the commands left at the end will be executed
				newpath=checkingParamter(args,paths,args_len,path,dir,path_len,file,newpath);
				if(newpath==NULL){
				}
				else {
					for(int i=0;i<args_len;i++){
					}
					forkMethod(args,newpath,args_len);
				}	
			}		
			free(choice);
   }//while(1)
}// main