Ejemplo n.º 1
0
N_NIMCALL(void, serve_521254)(TY521256 action) {
	TY521426* HEX3Aenv_521447;
	NimStringDesc* typ;
	nimfr("serve", "service.nim")
	HEX3Aenv_521447 = 0;
	nimln(180, "system.nim");
	HEX3Aenv_521447 = (TY521426*) newObj((&NTI521448), sizeof(TY521426));
	nimln(55, "service.nim");
	typ = getconfigvar_153334(((NimStringDesc*) &TMP10641));
	nimln(56, "service.nim");
	if (eqStrings(typ, ((NimStringDesc*) &TMP10642))) goto LA1;
	if (eqStrings(typ, ((NimStringDesc*) &TMP10643))) goto LA2;
	if (eqStrings(typ, ((NimStringDesc*) &TMP10628))) goto LA2;
	goto LA3;
	LA1: ;
	{
		{
			nimln(58, "service.nim");
			while (1) {
				NimStringDesc* line;
				NimStringDesc* LOC12;
				nimln(59, "service.nim");
				line = readline_13478(stdin);
				nimln(60, "service.nim");
				{
					if (!eqStrings(line, ((NimStringDesc*) &TMP10644))) goto LA10;
					exit(((NI) 0));
				}
				LA10: ;
				nimln(50, "service.nim");
				LOC12 = 0;
				LOC12 = curcaascmd_521204; curcaascmd_521204 = copyStringRC1(line);
				if (LOC12) nimGCunrefNoCycle(LOC12);
				nimln(51, "service.nim");
				processcmdline_521209(((NU8) 1), line);
				nimln(52, "service.nim");
				action();
				nimln(53, "service.nim");
				gerrorcounter_163012 = ((NI) 0);
				nimln(62, "service.nim");
				printf("%s\012", ((NimStringDesc*) &TMP10628)? (((NimStringDesc*) &TMP10628))->data:"nil");
				nimln(63, "service.nim");
				fflush(stdout);
			}
		}
	}
	goto LA4;
	LA2: ;
	{
		Socketimpl513407* server;
		NimStringDesc* p;
		NU16 port;
		NimStringDesc* LOC20;
		NimStringDesc* inp;
		TY163054 LOC21;
		nimln(67, "service.nim");
		server = newsocket_513830(((NU8) 2), ((NU8) 1), ((NU8) 6), NIM_TRUE);
		nimln(68, "service.nim");
		p = getconfigvar_153334(((NimStringDesc*) &TMP10647));
		nimln(69, "service.nim");
		{
			NI LOC18;
			if (!(((NI) 0) < (p ? p->Sup.len : 0))) goto LA16;
			LOC18 = 0;
			LOC18 = nsuParseInt(p);
			port = ((NU16) (LOC18));
		}
		goto LA14;
		LA16: ;
		{
			port = ((NU16) 6000);
		}
		LA14: ;
		nimln(70, "service.nim");
		LOC20 = 0;
		LOC20 = getconfigvar_153334(((NimStringDesc*) &TMP10648));
		bindaddr_514620(server, port, LOC20);
		nimln(71, "service.nim");
		inp = copyString(((NimStringDesc*) &TMP10628));
		nimln(72, "service.nim");
		listen_514610(server, SOMAXCONN);
		nimln(73, "service.nim");
		asgnRefNoCycle((void**) (&(*HEX3Aenv_521447).stdoutsocket521408), newsocket_513830(((NU8) 2), ((NU8) 1), ((NU8) 6), NIM_TRUE));
		nimln(74, "service.nim");
		memset((void*)(&LOC21), 0, sizeof(LOC21));
		LOC21.ClPrc = HEX3Aanonymous_521409; LOC21.ClEnv = HEX3Aenv_521447;
		asgnRef((void**) (&writelnhook_163057.ClEnv), LOC21.ClEnv);
		writelnhook_163057.ClPrc = LOC21.ClPrc;
		{
			nimln(77, "service.nim");
			while (1) {
				NimStringDesc* LOC24;
				nimln(78, "service.nim");
				accept_515401(server, &(*HEX3Aenv_521447).stdoutsocket521408, 2);
				nimln(79, "service.nim");
				readline_517608((*HEX3Aenv_521447).stdoutsocket521408, (&inp), ((NI) -1), 2);
				nimln(50, "service.nim");
				LOC24 = 0;
				LOC24 = curcaascmd_521204; curcaascmd_521204 = copyStringRC1(inp);
				if (LOC24) nimGCunrefNoCycle(LOC24);
				nimln(51, "service.nim");
				processcmdline_521209(((NU8) 1), inp);
				nimln(52, "service.nim");
				action();
				nimln(53, "service.nim");
				gerrorcounter_163012 = ((NI) 0);
				nimln(81, "service.nim");
				send_518208((*HEX3Aenv_521447).stdoutsocket521408, ((NimStringDesc*) &TMP10651), 2);
				nimln(82, "service.nim");
				close_515417((*HEX3Aenv_521447).stdoutsocket521408);
			}
		}
	}
	goto LA4;
	LA3: ;
	{
		nimln(86, "service.nim");
		printf("%s%s\012", ((NimStringDesc*) &TMP10674)? (((NimStringDesc*) &TMP10674))->data:"nil", typ? (typ)->data:"nil");
		nimln(87, "service.nim");
		msgquit_163104(((NI8) 1));
	}
	LA4: ;
	popFrame();
}
Ejemplo n.º 2
0
N_NIMCALL(void, serve_521257)(TY521259 action) {
	TY521428* HEX3Aenv_521449;
	NimStringDesc* typ;
	HEX3Aenv_521449 = 0;
	HEX3Aenv_521449 = (TY521428*) newObj((&NTI521450), sizeof(TY521428));
	typ = getconfigvar_153340(((NimStringDesc*) &TMP4988));
	if (eqStrings(typ, ((NimStringDesc*) &TMP4989))) goto LA1;
	if (eqStrings(typ, ((NimStringDesc*) &TMP4990))) goto LA2;
	if (eqStrings(typ, ((NimStringDesc*) &TMP1075))) goto LA2;
	goto LA3;
	LA1: ;
	{
		{
			while (1) {
				NimStringDesc* line;
				NimStringDesc* LOC12;
				line = readline_13478(stdin);
				{
					if (!eqStrings(line, ((NimStringDesc*) &TMP4992))) goto LA10;
					exit(((NI) 0));
				}
				LA10: ;
				LOC12 = 0;
				LOC12 = curcaascmd_521204; curcaascmd_521204 = copyStringRC1(line);
				if (LOC12) nimGCunrefNoCycle(LOC12);
				processcmdline_521209(((NU8) 1), line);
				action();
				gerrorcounter_163016 = ((NI) 0);
				printf("%s\012", ((NimStringDesc*) &TMP1075)? (((NimStringDesc*) &TMP1075))->data:"nil");
				fflush(stdout);
			}
		}
	}
	goto LA4;
	LA2: ;
	{
		Socketimpl513407* server;
		NimStringDesc* p;
		NU16 port;
		NimStringDesc* LOC20;
		NimStringDesc* inp;
		TY163060 LOC21;
		server = newsocket_513830(((NU8) 2), ((NU8) 1), ((NU8) 6), NIM_TRUE);
		p = getconfigvar_153340(((NimStringDesc*) &TMP4993));
		{
			NI LOC18;
			if (!(((NI) 0) < (p ? p->Sup.len : 0))) goto LA16;
			LOC18 = 0;
			LOC18 = nsuParseInt(p);
			port = ((NU16) (LOC18));
		}
		goto LA14;
		LA16: ;
		{
			port = ((NU16) 6000);
		}
		LA14: ;
		LOC20 = 0;
		LOC20 = getconfigvar_153340(((NimStringDesc*) &TMP4994));
		bindaddr_514620(server, port, LOC20);
		inp = copyString(((NimStringDesc*) &TMP1075));
		listen_514610(server, SOMAXCONN);
		asgnRefNoCycle((void**) (&(*HEX3Aenv_521449).stdoutsocket521408), newsocket_513830(((NU8) 2), ((NU8) 1), ((NU8) 6), NIM_TRUE));
		memset((void*)(&LOC21), 0, sizeof(LOC21));
		LOC21.ClPrc = HEX3Aanonymous_521409; LOC21.ClEnv = HEX3Aenv_521449;
		asgnRef((void**) (&writelnhook_163063.ClEnv), LOC21.ClEnv);
		writelnhook_163063.ClPrc = LOC21.ClPrc;
		{
			while (1) {
				NimStringDesc* LOC24;
				accept_515401(server, &(*HEX3Aenv_521449).stdoutsocket521408, 2);
				readline_517608((*HEX3Aenv_521449).stdoutsocket521408, (&inp), ((NI) -1), 2);
				LOC24 = 0;
				LOC24 = curcaascmd_521204; curcaascmd_521204 = copyStringRC1(inp);
				if (LOC24) nimGCunrefNoCycle(LOC24);
				processcmdline_521209(((NU8) 1), inp);
				action();
				gerrorcounter_163016 = ((NI) 0);
				send_518208((*HEX3Aenv_521449).stdoutsocket521408, ((NimStringDesc*) &TMP4997), 2);
				close_515417((*HEX3Aenv_521449).stdoutsocket521408);
			}
		}
	}
	goto LA4;
	LA3: ;
	{
		printf("%s%s\012", ((NimStringDesc*) &TMP5006)? (((NimStringDesc*) &TMP5006))->data:"nil", typ? (typ)->data:"nil");
		msgquit_163112(((NI8) 1));
	}
	LA4: ;
}