示例#1
0
void mapreduce_map_all(mapreduce_t *mr, const char **values)
{
	if (values == NULL){return;}
// ******************************** VARIABLES DECLARATION *********************************
	int size = size_of_array(values); 

	int ** pipe_arr = malloc(sizeof(int *) * size);

	int i = 0, curr = 0; 
// ******************************** INIT PIPES ********************************************
	for (i = 0; i < size; i++){
		pipe_arr[i] = malloc(sizeof(int) * 2); 
		pipe_arr[i][0] = -1;
		pipe_arr[i][1] = -1; 
		pipe(pipe_arr[i]); 
	}

	for(curr = 0; curr < size; curr++){

		if (fork() == 0){
			close(pipe_arr[curr][0]);
			//printf("This is what I am sending %s\n", values[curr]);
			mr->mymap_function(pipe_arr[curr][1], values[curr]);
  			exit(0);
		}
		close(pipe_arr[curr][1]);

	}
	mr -> pipes = pipe_arr;
	mr -> size = size; 

	pthread_create(&worker_thread, NULL, worker_function, (void *) mr);

}
void isColorPickerDlg::btnOKClick(wxCommandEvent& event)
{
	int nmsg;
	HWND results[100];
	results[0] = 0;
	EnumWindows(EnumWindowsProc,(long)results);
	nmsg = size_of_array(results);

	if (nmsg == 0) //No versions of Scite are open. 
	{
		//res = launch_scite(args[0], "output:Now that worked.");
		//if (res)
		//	retstr = istrdup("new:success");
		//else
		//	retstr = istrdup("new:failure");
	}
	else //Pick the first instance of Scite found.
	{
		wxString params;
		params = "extender:import scmsg; scmsg.sd(\"," + IntToString(rSlider->GetValue()) + "," +
		 IntToString(gSlider->GetValue()) + "," +IntToString(bSlider->GetValue()) + "," + textHex->GetValue() +
		 ",\")";
		
		SendToHandle(results[0], params.c_str());
		rSlider->SetValue(255);
	}
		
	Close(true);
}
示例#3
0
int _tmain(int argc, _TCHAR* argv[])
{
	if (argc < 3)
	{
		puts(documentation);
		return 1;
	}
	const char* strHwnd = argv[1];
	const char* strAction = argv[2];

	char *containsColon = strchr(strAction, ':');
	if (! containsColon)
	{
		fputs("Invalid command. Should be in form close: or insert:hello", stderr);
		return 1;
	}

	if (strcmp(strHwnd, "find")==0)
	{
		HWND results[30];
		results[0] = 0;
		EnumWindows(EnumWindowsProc,(LPARAM) results);
		int nResults = size_of_array(results);

		if (nResults == 0)
		{
			fputs("Could not find an open instance of SciTE", stderr);
			return 1;
		}
		else 
		{
			//Pick the first instance of Scite found.
			//Assumes backslashes have been added by the input
			
			SendToHandle(results[0], strAction);
		}
	}
	else
	{
		// NOTE: not 64-bit safe. Is there a 64bit atoi?
		long nHwnd = atol(strHwnd);
		if (nHwnd==0 || nHwnd==LONG_MAX || nHwnd==LONG_MIN)
		{
			fputs("Invalid hwnd. Should be in decimal", stderr);
			return 1;
		}
		HWND hwnd = (HWND) nHwnd;

		SendToHandle(hwnd, strAction);
	}

	return 0;
}
示例#4
0
int main(int argc, char **argv) {
	// test shell config	
	struct stat shelltest;
	struct wordnode* commands; //head for list of possible paths to commands
	int rv = stat("shell-config", &shelltest);
	if (rv < 0) {
   	 	printf("shell-config DNE. Please enter full path");
	}	
	else {
		int num_words = 0;	
		commands = load_commands("shell-config",&num_words);
		//commands = "/bin/";
	}
		
	char prompt[] = "prompt> ";	
	printf("%s",prompt);
	fflush(stdout);

	int m=0; //keep track of mode
	char buffer[1024];
	while (fgets(buffer, 1024, stdin) != NULL) {
						
		
		//handles comments, but only at the end of command		
		int i=0;	
		while (buffer[i]!='\0') {
			if (buffer[i]=='#') {
				buffer[i] = '\0';
				i--;
			}
			i++;
		}
		//
		int size = size_of_array(buffer);		
		char** argv = (char**) malloc(sizeof(char*)*(size+1));
		make_array(buffer,argv,size);		
		
		//print_array(argv,size);
		//printf("%d\n", size);

		
		
		if (m==0) {
			m = run_sequential(argv,size,commands);
		}
		
		else if (m==1) {
			m = run_par(argv,size);
			//pid_t pid;
			//int num;
			/*while ((pid = waitpid(-1, &stat, WNOHANG))>0) {
				printf("child process finished /n");
			}*/
		  
		}
	
		
	
	printf("%s",prompt);

	} // end shell while loop
	free(argv);
	free_wordlist(commands);
    return 0;
}