Exemple #1
0
int konoha_main(konoha_t konoha, int argc, const char **argv)
{
	CTX ctx = (CTX)konoha;
	int i, ret = 0, n = knh_parseopt(ctx, argc, argv);
	knh_linkDynamicReadline(ctx);
	knh_linkDynamicRegex(ctx);
	knh_linkDynamicIconv(ctx);
	for (i = 0; konoha_modules[i].init != NULL; ++i) {
		konoha_modules[i].init(argc, n, argv);
	}
	argc = argc - n;
	argv = argv + n;
	if(isActorMode) {
		char portstr[6] = {0};
		knh_snprintf(portstr, sizeof(portstr), "%d", port);
		const char *argv_actor[3] = {"actsrv", portstr, NULL};
		argc = 2;
		argv = argv_actor;
	}
	knh_parsearg(ctx, argc, argv);
	if(argc == 0) {
		ret = konoha_shell(ctx, NULL);
	}
	else if(isMPIMode) {
		kMPI_argv0 = argv[0];
		knh_loadPackage(ctx, STEXT("konoha.mpi"));
		knh_eval(ctx, "using konoha.mpi.*; int main(String[] args) { new TaskScript().exec(MPI.vload()); MPI.vmainloop(); return 0 }", 1, NULL);
		ret = knh_runMain(ctx, argc, argv);
	}
	else {
		if(knh_startScript(ctx, argv[0]) == K_CONTINUE && !knh_isCompileOnly(ctx)) {
			ret = knh_runMain(ctx, argc, argv);
			if(isInteractiveMode) {
				konoha_shell(ctx, NULL);
			}
		}
	}
	for (i = 0; konoha_modules[i].exit != NULL; ++i) {
		konoha_modules[i].exit();
	}
	return ret;
}
Exemple #2
0
int konoha_main(konoha_t konoha, int argc, const char **argv)
{
	CTX ctx = (CTX)konoha;
	int i, ret = 0, n = knh_parseopt(ctx, argc, argv);
	knh_linkDynamicReadline(ctx);
	knh_linkDynamicRegex(ctx);
	knh_linkDynamicIconv(ctx);
	for (i = 0; konoha_modules[i].init != NULL; ++i) {
		konoha_modules[i].init(argc, n, argv);
	}
	argc = argc - n;
	argv = argv + n;
	if(isActorMode) {
		char portstr[6] = {0};
		knh_snprintf(portstr, sizeof(portstr), "%d", port);
		const char *argv_actor[3] = {"actsrv", portstr, NULL};
		argc = 2;
		argv = argv_actor;
	}
	knh_parsearg(ctx, argc, argv);
	if(argc == 0) {
		ret = konoha_shell(ctx, NULL);
	}
	else {
		if(knh_startScript(ctx, argv[0]) == K_CONTINUE && !knh_isCompileOnly(ctx)) {
			ret = knh_runMain(ctx, argc, argv);
			if(isInteractiveMode) {
				konoha_shell(ctx, NULL);
			}
		}
	}
	for (i = 0; konoha_modules[i].exit != NULL; ++i) {
		konoha_modules[i].exit();
	}
	return ret;
}