Beispiel #1
0
void
VETypeList::ScanAtLaunch()
{

	// Validate pointers.
	
	ValidateThis_();

	// Find application file.
	
	FSSpec appFile;
	UApplicationFile::GetApplicationFile(appFile);

	// Read from application file.
	
	{
		StApplicationContext appContext;
		StValueChanger<Boolean> builtIn(mTypesAreBuiltIn, true);
		ScanCurrentResourceFile(appFile);
	}

	// Read application folder.
	
	try {
		ScanFolderForPlugIns(appFile.vRefNum, appFile.parID);
	}
	catch(...) {
		// ignore errors
	}

	// Read "Constructor Plugins" folder in same folder as application
	
	// find the folder
	
	CInfoPBRec folderInfo;
	LStr255 folderName(STR_TargetInfo, str_PluginsFolderName);
	
	folderInfo.hFileInfo.ioCompletion = nil;
	folderInfo.hFileInfo.ioNamePtr = (StringPtr) folderName;
	folderInfo.hFileInfo.ioVRefNum = appFile.vRefNum;
	folderInfo.hFileInfo.ioFDirIndex = 0;
	folderInfo.hFileInfo.ioDirID = appFile.parID;
	
	OSErr err = ::PBGetCatInfoSync( &folderInfo );
	
	if (err == noErr) {
	
		// read it
	
		try {
			ScanFolderForPlugIns(folderInfo.hFileInfo.ioVRefNum,
									folderInfo.hFileInfo.ioDirID);
		}
		catch(...) {
			// ignore errors
		}
	}
}
Beispiel #2
0
int main(int argc, char **argv) {
	
	struct rusage usageBegin;
	getrusage(RUSAGE_SELF, &usageBegin);

	char *prompt = ";) ";
	printf("%s", prompt);
	fflush(stdout);
	int sequential = 1;

	struct node* tasks = NULL;

	struct node *paths = NULL;
	struct stat haspath;
	int canhas = stat("shell-config", &haspath);
	if(canhas==0){
		FILE * pathfile = fopen("shell-config", "r");		
		char* pathline = malloc(128*sizeof(char));
		while(fgets(pathline, 128, pathfile) != NULL){
			pathline[strlen(pathline)-1] = '/';
			list_insert(pathline, &paths);
		}
		free(pathline);
		fclose(pathfile);
	}

	char buffer[1024] = "initialized";
	int polloop = 1;
	while(polloop ==1){
		struct pollfd pfd = {0, POLLIN}; //"In" events check
		int input = poll(&pfd, 1, 1000); //Input will be a 1=yes, 0=no input in the past second.
		if(input ==0){
			//run through the grand linked list of background processes.
			struct node *checkup = tasks;
			struct node *suture = tasks;
			int checkstatus = 0;
			while(checkup!=NULL){
				pid_t childp = waitpid((*checkup).pid, &checkstatus, WNOHANG);
				if(childp != 0){
					printf("Parent got carcass of child process %d, return val %d\n", childp, checkstatus);
					if(checkup == tasks){
						tasks = (*checkup).next;
						free(checkup);
						checkup = tasks;
					}else{
						(*suture).next = (*checkup).next;
						free(checkup);
						checkup = (*suture).next;
					}
				}else{
					if(checkup != tasks){
						suture = (*suture).next;
					}
					checkup = (*checkup).next;
				}
			}

		} else if(input<0){
			//probably need to free junk before exit.
			polloop = 0;
		}else{
			//run our fgets and do stuff with their commands.
	
			if(fgets(buffer, 1024, stdin) != NULL){
				int buflen = 1023;
				int i = 0;
				while( i<buflen && buffer[i] != '#'){
					i++;
				}
				buffer[i] = '\0';
				buflen = i-1;
				//printf("Buffer:%s", buffer);
				char *** cmd = parseCommand(buffer);
				//char* test = "a b c d e f g";
				//char*** cmd[2] = {tokenify(test), NULL}; 
				/*int a = 0;
				int b = 0;
				for(; cmd[a]!=NULL; a++){
					for(; (cmd[a])[b] != NULL; b++){
						printf("Command: %s\n", (cmd[a])[b]);
					}
					b=0;
				}*/
		

				int com = 0; //Will be used to increment through cmd
				int built;
				//Sequential Running of cmd:
				for(; sequential==1 && cmd[com] != NULL; com++){	
					built = builtIn(cmd[com]);
					if(built == 1){
						sequential = changeMode(sequential, (cmd[com])[1]);
					} else if(built == -1){
						sequential = -1;
					} else{
						sequential = runSeq(cmd[com], paths);
					}
				}	
				int*** newpros;
				if (sequential == 0 && cmd[com]!=NULL){					
					newpros = parallel(cmd+com, paths, tasks);	
					sequential = (newpros[0])[0][0];
					if(sequential!=-2){
						int index = newpros[1][0][0];
						for(;index > 1; index--){
							/*printf("Index points:%p, Index is:%d\n", newpros[index], index);
							printf("Index[1] points:%p\n", newpros[index][1]);
							printf("Index[1][0] points:%d\n", newpros[index][1][0]);*/
							if(newpros[index][1][0]>0){
								list_insert( (char*)newpros[index][0], &tasks);
								(*tasks).pid = *(newpros[index][1]);
								(*tasks).status = 1; //1 for running
							}
							free(newpros[index][1]);
							free(newpros[index][0]);
							free(newpros[index]);	
						}
						free(newpros);
					}
				}
				if(sequential == -2){
					free(newpros[0][0]);
					free(newpros[0]);
					free(newpros);
					exit(2);
				}
				freeCmd(cmd);
				free(cmd);
				if(sequential == -1){ //totally wrong. fix. -- fixed 
					if(tasks!=NULL){
						struct node *waiter = tasks;
						while(waiter!=NULL){
							int rstatus = 0;
							pid_t childp = waitpid((*waiter).pid, &rstatus,0); 
							printf("Parent got carcass of child process %d, return val %d\n", childp, rstatus);
							waiter = (*waiter).next;
						}
						while((*tasks).next!=NULL){
							waiter = (*tasks).next;
							free(tasks);
							tasks = waiter;
						}
					free(tasks);
					}
					exitUsage(&usageBegin);
					exit(2);
				}
				printf("%s", prompt);
				fflush(stdout);
			}else{
				polloop = -1;
			}
		}
	}
	exitUsage(&usageBegin);
	printf("exited\n");
	return 0;	
}