void main(int argc, char **argv) { int going = TRUE, forsok = 2,car = 1, tmp, ch; long tid; char tellstr[100],*tmppscreen, titel[80]; NewList((struct List *)&aliaslist); NewList((struct List *)&edit_list); if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0))) cleanup(EXIT_ERROR,"Kunde inte öppna intuition.library\n"); if(!(UtilityBase=OpenLibrary("utility.library",37L))) cleanup(EXIT_ERROR,"Kunde inte öppna utility.library\n"); if(!(LocaleBase=OpenLibrary("locale.library",38L))) cleanup(EXIT_ERROR,"Kunde inte öppna locale.library\n"); if(!(NiKomBase=OpenLibrary("nikom.library",0L))) cleanup(EXIT_ERROR,"Kunde inte öppna nikom.linbrary"); getnodeconfig("NiKom:Datocfg/ConNode.cfg"); if(!(initnode(NODCON))) cleanup(EXIT_ERROR,"Kunde inte registrera noden i Servern\n"); if(!(nikomnodeport = CreateMsgPort())) cleanup(EXIT_ERROR,"Kunde inte skapa NiKomNode-porten"); sprintf(nikomnodeportnamn,"NiKomNode%d",nodnr); nikomnodeport->mp_Node.ln_Name = nikomnodeportnamn; nikomnodeport->mp_Node.ln_Pri = 1; AddPort(nikomnodeport); sprintf(rexxportnamn,"NiKomRexx%d",nodnr); if(!(rexxport=(struct MsgPort *)CreateMsgPort())) cleanup(EXIT_ERROR,"Kunde inte öppna RexxPort\n"); rexxport->mp_Node.ln_Name=rexxportnamn; rexxport->mp_Node.ln_Pri=50; AddPort(rexxport); if(!(RexxSysBase=(struct RsxLib *)OpenLibrary("rexxsyslib.library",0L))) cleanup(EXIT_ERROR,"Kunde inte öppna rexxsyslib.library\n"); if(pubscreen[0]=='-') tmppscreen=NULL; else tmppscreen=pubscreen; if(!(NiKwind=(struct Window *)OpenWindowTags(NULL,WA_Left,xpos, WA_Top,ypos, WA_Width,xsize, WA_Height,ysize, WA_IDCMP,IDCMP_CLOSEWINDOW, WA_MinWidth,50, WA_MinHeight,10, WA_MaxWidth,~0, WA_MaxHeight,~0, WA_SizeGadget,TRUE, WA_SizeBBottom, TRUE, WA_DragBar,TRUE, WA_DepthGadget,TRUE, WA_CloseGadget,TRUE, WA_SimpleRefresh,TRUE, WA_ScreenTitle,"NiKomCon", WA_AutoAdjust,TRUE, WA_PubScreenName,tmppscreen, TAG_DONE))) cleanup(EXIT_ERROR,"Kunde inte öppna fönstret\n"); if(!OpenIO(NiKwind)) cleanup(EXIT_ERROR,"Kunde inte öppna IO\n"); strcpy(Servermem->nodid[nodnr],nodid); sprintf(titel,"Nod #%d CON: <Ingen inloggad>",nodnr); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); Servermem->connectbps[nodnr] = -1; conreqtkn(); do { Servermem->idletime[nodnr] = time(NULL); memset(commandhistory,0,1024); Servermem->inne[nodnr].rader=0; sendfile("NiKom:Texter/Inlogg.txt"); if(Servermem->cfg.ar.preinlogg) sendautorexx(Servermem->cfg.ar.preinlogg); going=TRUE; while(going) { Servermem->idletime[nodnr] = time(NULL); puttekn("\r\nNamn: ",-1); getstring(EKO,40,NULL); if(!stricmp(inmat,Servermem->cfg.ny)) { tmp = RegisterNewUser(); if(tmp == 2) { goto panik; } car = tmp ? 0 : 1; going=FALSE; } else if((inloggad=parsenamn(inmat))>=0) { if(readuser(inloggad,&Servermem->inne[nodnr])) { puttekn("Error reading user data.\r\n", -1); goto panik; } // TODO: Extract password loop. Should be identical to in PreNode/Ser.c forsok=2; while(forsok) { puttekn("\r\nLösen: ",-1); if(Servermem->inne[nodnr].flaggor & STAREKOFLAG) getstring(STAREKO,15,NULL); else getstring(EJEKO,15,NULL); if(CheckPassword(inmat, Servermem->inne[nodnr].losen)) { forsok=FALSE; going=FALSE; } else { forsok--; } } } else if(inloggad==-1) puttekn("\r\nHittar ej namnet\r\n",-1); } sprintf(titel,"Nod #%d CON: %s #%d",nodnr,Servermem->inne[nodnr].namn,inloggad); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); if(!ReadUnreadTexts(&Servermem->unreadTexts[nodnr], inloggad)) { puttekn("Error reading unread text info.\r\n", -1); LogEvent(SYSTEM_LOG, ERROR, "Can't read unread text info for user %d", inloggad); goto panik; } Servermem->inloggad[nodnr]=inloggad; Servermem->idletime[nodnr] = time(NULL); if(getft("NiKom:Texter/Bulletin.txt")>Servermem->inne[nodnr].senast_in) sendfile("NiKom:Texter/Bulletin.txt"); connection(); if(Servermem->cfg.logmask & LOG_UTLOGG) { LogEvent(USAGE_LOG, INFO, "%s loggar ut från nod %d", getusername(inloggad), nodnr); } if(Servermem->say[nodnr]) displaysay(); if(Servermem->cfg.ar.utlogg) sendautorexx(Servermem->cfg.ar.utlogg); sendfile("NiKom:Texter/Utlogg.txt"); sprintf(titel,"Nod #%d CON: <Ingen inloggad>",nodnr); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); Servermem->inloggad[nodnr]=-1; Servermem->action[nodnr]=0; time(&tid); Servermem->inne[nodnr].senast_in=tid; Servermem->inne[nodnr].tot_tid+=(tid-logintime); Servermem->inne[nodnr].loggin++; Servermem->info.inloggningar++; Servermem->inne[nodnr].defarea=area2; writeuser(inloggad,&Servermem->inne[nodnr]); WriteUnreadTexts(&Servermem->unreadTexts[nodnr], inloggad); writesenaste(); freealiasmem(); sprintf(tellstr,"loggade just ut från nod %d",nodnr); tellallnodes(tellstr); panik: nodestate = 0; puttekn("\r\n\nEn inloggning till? (J/n)",-1); } while((ch = GetChar()) != 'n' && ch != 'N'); cleanup(EXIT_OK,""); }
void main(int argc,char *argv[]) { int x; long tid; char tellstr[100],*tmppscreen, titel[80], configname[50] = "NiKom:DatoCfg/SerNode.cfg"; if(argc>1) for(x=1;x<argc;x++) { if(argv[x][0]=='-') { if(argv[x][1]=='B') dtespeed=atoi(&argv[x][2]); else if(argv[x][1]=='N') nodnr = atoi(&argv[x][2]); } else strcpy(configname,argv[x]); } if(nodnr==-1) { printf("NiKomSer måste startas från prenoden.\n"); exit(10); } NewList((struct List *)&aliaslist); NewList((struct List *)&edit_list); if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0))) cleanup(EXIT_ERROR,"Kunde inte öppna intuition.library\n"); if(!(UtilityBase=OpenLibrary("utility.library",37L))) cleanup(EXIT_ERROR,"Kunde inte öppna utility.library\n"); if(!(LocaleBase=OpenLibrary("locale.library",38L))) cleanup(EXIT_ERROR,"Kunde inte öppna locale.library\n"); if(!(NiKomBase=OpenLibrary("nikom.library",0L))) cleanup(EXIT_ERROR,"Kunde inte öppna nikom.library\n"); initnode(NODSPAWNED); if(!(nikomnodeport = CreateMsgPort())) cleanup(EXIT_ERROR,"Kunde inte skapa NiKomNode-porten"); sprintf(nikomnodeportnamn,"NiKomNode%d",nodnr); nikomnodeport->mp_Node.ln_Name = nikomnodeportnamn; nikomnodeport->mp_Node.ln_Pri = 1; AddPort(nikomnodeport); sprintf(rexxportnamn,"NiKomRexx%d",nodnr); if(!(rexxport=(struct MsgPort *)CreateMsgPort())) cleanup(EXIT_ERROR,"Kunde inte öppna RexxPort\n"); rexxport->mp_Node.ln_Name=rexxportnamn; rexxport->mp_Node.ln_Pri = 50; AddPort(rexxport); if(!(RexxSysBase=(struct RsxLib *)OpenLibrary("rexxsyslib.library",0L))) cleanup(EXIT_ERROR,"Kunde inte öppna rexxsyslib.library\n"); getnodeconfig(configname); if(pubscreen[0]=='-') tmppscreen=NULL; else tmppscreen=pubscreen; if(!(NiKwind=(struct Window *)OpenWindowTags(NULL,WA_Left,xpos, WA_Top,ypos, WA_Width,xsize, WA_Height,ysize, WA_IDCMP,IDCMP_CLOSEWINDOW, WA_MinWidth,50, WA_MinHeight,10, WA_MaxWidth,~0, WA_MaxHeight,~0, WA_SizeGadget,TRUE, WA_SizeBBottom, TRUE, WA_DragBar,TRUE, WA_DepthGadget,TRUE, WA_CloseGadget,TRUE, WA_SimpleRefresh,TRUE, WA_ScreenTitle,"NiKomSer", WA_AutoAdjust,TRUE, WA_PubScreenName,tmppscreen, TAG_DONE))) cleanup(EXIT_ERROR,"Kunde inte öppna fönstret\n"); if(!OpenIO(NiKwind)) cleanup(EXIT_ERROR,"Kunde inte öppna IO\n"); inloggad=Servermem->inloggad[nodnr]; conreqtkn(); serreqtkn(); UpdateInactive(); sprintf(titel,"Nod #%d SER: %s #%d",nodnr,Servermem->inne[nodnr].namn,inloggad); SetWindowTitles(NiKwind,titel,(char *)-1L); if(!ReadUnreadTexts(&Servermem->unreadTexts[nodnr], inloggad)) { puttekn("Error reading unread text info.\r\n", -1); LogEvent(SYSTEM_LOG, ERROR, "Can't read unread text info for user %d", inloggad); cleanup(EXIT_ERROR, "Error reading unread text info.\n"); } if(getft("NiKom:Texter/Bulletin.txt")>Servermem->inne[nodnr].senast_in) { sendfile("NiKom:Texter/Bulletin.txt"); } connection(); if(nodestate & NIKSTATE_NOCARRIER) { conputtekn("\nCarrier dropped\n",-1); if(Servermem->cfg.logmask & LOG_CARDROPPED) { LogEvent(USAGE_LOG, WARN, "%s släpper carriern (nod %d)", getusername(inloggad), nodnr); } if(Servermem->cfg.ar.cardropped) sendautorexx(Servermem->cfg.ar.cardropped); } else { if(nodestate & NIKSTATE_AUTOLOGOUT) { puttekn("\n\n\r*** Automagisk utloggning ***\n\n\r",-1); } else if(nodestate & NIKSTATE_INACTIVITY) { puttekn("\n\n\r*** Utloggning p.g.a inaktivitet ***\n\n\r",-1); } radcnt=-174711; if(Servermem->say[nodnr]) displaysay(); if(Servermem->cfg.ar.utlogg) sendautorexx(Servermem->cfg.ar.utlogg); sendfile("NiKom:Texter/Utlogg.txt"); } Servermem->inloggad[nodnr]=-1; if(Servermem->cfg.logmask & LOG_UTLOGG) { LogEvent(USAGE_LOG, INFO, "%s loggar ut från nod %d", getusername(inloggad), nodnr); } Servermem->action[nodnr]=0; time(&tid); Servermem->inne[nodnr].senast_in=tid; Servermem->inne[nodnr].tot_tid+=(tid-logintime); Servermem->inne[nodnr].loggin++; Servermem->info.inloggningar++; Servermem->inne[nodnr].defarea=area2; writeuser(inloggad,&Servermem->inne[nodnr]); WriteUnreadTexts(&Servermem->unreadTexts[nodnr], inloggad); writesenaste(); AbortInactive(); freealiasmem(); sprintf(tellstr,"loggade just ut från nod %d",nodnr); tellallnodes(tellstr); if(nodestate & NIKSTATE_NOCARRIER) { nodestate &= ~NIKSTATE_RELOGIN; } nodestate &= (NIKSTATE_RELOGIN | NIKSTATE_CLOSESER | NIKSTATE_NOANSWER); cleanup(nodestate,""); }
void main(int argc, char **argv) { int going=TRUE,forsok=2,car=1; long tid; char tellstr[100],*tmppscreen, titel[80]; UBYTE tillftkn; NewList((struct List *)&aliaslist); NewList((struct List *)&edit_list); if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0))) cleanup(ERROR,"Kunde inte öppna intuition.library\n"); if(!(UtilityBase=OpenLibrary("utility.library",37L))) cleanup(ERROR,"Kunde inte öppna utility.library\n"); if(!(NiKomBase=OpenLibrary("nikom.library",0L))) cleanup(ERROR,"Kunde inte öppna nikom.linbrary"); getnodeconfig("NiKom:Datocfg/ConNode.cfg"); if(!(initnode(NODCON))) cleanup(ERROR,"Kunde inte registrera noden i Servern\n"); if(!(nikomnodeport = CreateMsgPort())) cleanup(ERROR,"Kunde inte skapa NiKomNode-porten"); sprintf(nikomnodeportnamn,"NiKomNode%d",nodnr); nikomnodeport->mp_Node.ln_Name = nikomnodeportnamn; nikomnodeport->mp_Node.ln_Pri = 1; AddPort(nikomnodeport); sprintf(rexxportnamn,"NiKomRexx%d",nodnr); if(!(rexxport=(struct MsgPort *)CreateMsgPort())) cleanup(ERROR,"Kunde inte öppna RexxPort\n"); rexxport->mp_Node.ln_Name=rexxportnamn; rexxport->mp_Node.ln_Pri=50; AddPort(rexxport); if(!(RexxSysBase=(struct RsxLib *)OpenLibrary("rexxsyslib.library",0L))) cleanup(ERROR,"Kunde inte öppna rexxsyslib.library\n"); if(pubscreen[0]=='-') tmppscreen=NULL; else tmppscreen=pubscreen; if(!(NiKwind=(struct Window *)OpenWindowTags(NULL,WA_Left,xpos, WA_Top,ypos, WA_Width,xsize, WA_Height,ysize, WA_IDCMP,IDCMP_CLOSEWINDOW, WA_MinWidth,50, WA_MinHeight,10, WA_MaxWidth,~0, WA_MaxHeight,~0, WA_SizeGadget,TRUE, WA_SizeBBottom, TRUE, WA_DragBar,TRUE, WA_DepthGadget,TRUE, WA_CloseGadget,TRUE, WA_SimpleRefresh,TRUE, WA_ScreenTitle,"NiKom © Tomas Kärki 1996-1998", WA_AutoAdjust,TRUE, WA_PubScreenName,tmppscreen, TAG_DONE))) cleanup(ERROR,"Kunde inte öppna fönstret\n"); if(!OpenIO(NiKwind)) cleanup(ERROR,"Kunde inte öppna IO\n"); if(!getkeyfile()) cleanup(ERROR,"Korrupt nyckelfil\n"); strcpy(Servermem->nodid[nodnr],nodid); sprintf(titel,"Nod #%d CON: <Ingen inloggad>",nodnr); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); Servermem->connectbps[nodnr] = -1; conreqtkn(); do { memset(commandhistory,0,1024); Servermem->inne[nodnr].rader=0; sendfile("NiKom:Texter/Inlogg.txt"); if(Servermem->cfg.ar.preinlogg) sendrexx(Servermem->cfg.ar.preinlogg); going=TRUE; while(going) { puttekn("\r\nNamn: ",-1); getstring(EKO,40,NULL); if(!stricmp(inmat,Servermem->cfg.ny)) { /* if(!reggadnamn[0] && ((struct ShortUser *)Servermem->user_list.mlh_TailPred)->nummer >= 4) puttekn("\n\n\rDenna demoversion av NiKom kan hantera maximalt 5 användare.\n\r",-1); else { Versionen är nu obegränsad 970930! */ if((car=nyanv())==2) goto panik; going=FALSE; /* } */ } else if((inloggad=parsenamn(inmat))>=0) { readuser(inloggad,&Servermem->inne[nodnr]); forsok=2; while(forsok) { puttekn("\r\nLösen: ",-1); if(Servermem->inne[nodnr].flaggor & STAREKOFLAG) getstring(STAREKO,15,NULL); else getstring(EJEKO,15,NULL); if(CheckPassword(inloggad, inmat)) { forsok=FALSE; going=FALSE; } else forsok--; } } else if(inloggad==-1) puttekn("\r\nHittar ej namnet\r\n",-1); } sprintf(titel,"Nod #%d CON: %s #%d",nodnr,Servermem->inne[nodnr].namn,inloggad); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); readuserbitmap(inloggad,Servermem->bitmaps[nodnr],0,temppek); Servermem->inloggad[nodnr]=inloggad; Servermem->idletime[nodnr] = time(NULL); if(getft("NiKom:Texter/Bulletin.txt")>Servermem->inne[nodnr].senast_in) sendfile("NiKom:Texter/Bulletin.txt"); connection(); if(Servermem->cfg.logmask & LOG_UTLOGG) { sprintf(outbuffer,"%s loggar ut från nod %d",getusername(inloggad),nodnr); logevent(outbuffer); } if(Servermem->say[nodnr]) displaysay(); if(Servermem->cfg.ar.utlogg) sendrexx(Servermem->cfg.ar.utlogg); sendfile("NiKom:Texter/Utlogg.txt"); sprintf(titel,"Nod #%d CON: <Ingen inloggad>",nodnr); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); SaveProgramCategory(inloggad); Servermem->inloggad[nodnr]=-1; Servermem->action[nodnr]=0; Servermem->inne[nodnr].textpek=textpek; time(&tid); Servermem->inne[nodnr].senast_in=tid; Servermem->inne[nodnr].tot_tid+=(tid-logintime); Servermem->inne[nodnr].loggin++; Servermem->info.inloggningar++; Servermem->inne[nodnr].defarea=area2; writeuser(inloggad,&Servermem->inne[nodnr]); writeuserbitmap(inloggad,Servermem->bitmaps[nodnr],0,temppek); writesenaste(); freealiasmem(); sprintf(tellstr,"loggade just ut från nod %d",nodnr); tellallnodes(tellstr); panik: puttekn("\r\n\nEn inloggning till? (J/n)",-1); } while((tillftkn=gettekn())!='n' && tillftkn!='N'); cleanup(OK,""); }