void main(int argc,char *argv[]) { int going=TRUE,forsok=2,car=1,x,connectbps, i, tmp; struct NodeType *nt; char *tmppscreen,commandstring[100], configname[50] = "NiKom:DatoCfg/SerNode.cfg"; FILE *fil; if(argc>1) for(x=1; x<argc; x++) { if(argv[x][0]=='-') { if(argv[x][1]=='G') getty=TRUE; else if(argv[x][1]=='B') gettybps=atoi(&argv[x][2]); else if(argv[x][1]=='C') connectbps = atoi(&argv[x][2]); } else strcpy(configname,argv[x]); } 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.library\n"); if(!initnode(NODSER)) 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,"NiKomPreRexx%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"); getnodeconfig(configname); if(pubscreen[0]=='-') tmppscreen=NULL; else tmppscreen=pubscreen; if(!(NiKwind=openmywindow(tmppscreen))) cleanup(ERROR,"Kunde inte öppna fönstret\n"); if(getty) dtespeed = gettybps; else dtespeed = highbaud; if(!OpenIO(NiKwind)) cleanup(ERROR,"Couldn't setup IO"); strcpy(Servermem->nodid[nodnr],nodid); conreqtkn(); serreqtkn(); Delay(50); for(;;) { inloggad=-1; Servermem->idletime[nodnr] = time(NULL); Servermem->inloggad[nodnr]=-1; if(getty) Servermem->connectbps[nodnr] = connectbps; else waitconnect(); Servermem->idletime[nodnr] = time(NULL); Servermem->inloggad[nodnr]=-2; /* Sätt till <Uppringd> för att även hantera -getty-fallet */ reloginspec: updateinactive(); Servermem->inne[nodnr].flaggor = Servermem->cfg.defaultflags; if(!getty) Delay(100); Servermem->inne[nodnr].rader=0; Servermem->inne[nodnr].chrset = CHRS_LATIN1; sendfile("NiKom:Texter/Inlogg.txt"); if(Servermem->cfg.ar.preinlogg) sendrexx(Servermem->cfg.ar.preinlogg); car=TRUE; Servermem->inne[nodnr].chrset = 0; memset(commandhistory,0,1000); going=1; while(going && going<=Servermem->cfg.logintries) { putstring("\r\nNamn: ",-1,0); if(getstring(EKO,40,NULL)) { car=FALSE; break; } if(!stricmp(inmat,Servermem->cfg.ny) && !(Servermem->cfg.cfgflags & NICFG_CLOSEDBBS)) { 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 NiKomCon.c forsok=2; while(forsok) { puttekn("\r\nLösen: ",-1); if(Servermem->inne[nodnr].flaggor & STAREKOFLAG) { if(getstring(STAREKO,15,NULL)) { car=FALSE; break; } } else { if(getstring(EJEKO,15,NULL)) { car=FALSE; break; } } if(CheckPassword(inmat, Servermem->inne[nodnr].losen)) { forsok=FALSE; going=FALSE; } else forsok--; } if(going && (Servermem->cfg.logmask & LOG_FAILINLOGG)) { LogEvent(USAGE_LOG, WARN, "Nod %d, %s angivet som namn, fel lösen.", nodnr, getusername(inloggad)); } if(going) going++; } else if(inloggad==-1) puttekn("\r\nHittar ej namnet\r\n",-1); } if(!car) { if(getty) cleanup(OK,""); disconnect(); continue; } if(going) { putstring("\n\n\rTyvärr. Du har försökt maximalt antal gånger att logga in. Kopplar ned.\n\r",-1,0); goto panik; /* Urrk vad fult. :-) */ } Servermem->inloggad[nodnr]=inloggad; Servermem->idletime[nodnr] = time(NULL); if((nt = selectNodeType()) == NULL) { goto panik; } abortinactive(); abortserial(); sprintf(commandstring,"%s -N%d -B%d %s",nt->path,nodnr,dtespeed,configname); CloseConsole(); CloseWindow(NiKwind); NiKwind = NULL; RemPort(nikomnodeport); i = 0; if(Servermem->connectbps[nodnr] > 0) { while(Servermem->info.bps[i] != Servermem->connectbps[nodnr] && Servermem->info.bps[i] > 0 && i<49) i++; if(i<49) { if(Servermem->info.bps[i] == Servermem->connectbps[nodnr]) Servermem->info.antbps[i]++; else { Servermem->info.bps[i] = Servermem->connectbps[nodnr]; Servermem->info.antbps[i]++; } } if(!(fil = fopen("NiKom:datocfg/sysinfo.dat","w"))) { /* putstring("Kunde inte spara nya sysinfo.dat..\n",-1,0); */ } if(fwrite((void *)&Servermem->info,sizeof(Servermem->info),1,fil) != 1) { /* putstring("Kunde inte skriva till nya sysinfo.dat....\n",-1,0); */ } fclose(fil); } nodestate = SystemTags(commandstring, SYS_UserShell, TRUE, TAG_DONE); AddPort(nikomnodeport); if(!getty || (nodestate & NIKSTATE_RELOGIN)) { if(!(NiKwind = openmywindow(tmppscreen))) cleanup(ERROR,"Kunde inte öppna fönstret\n"); OpenConsole(NiKwind); } serreqtkn(); if(nodestate & NIKSTATE_RELOGIN) goto reloginspec; panik: Delay(hangupdelay); if(getty) cleanup(OK,""); disconnect(); } }
int sendbinfile(void) { struct TransferFiles *tf; int xprreturkod,cnt=0; if(!(XProtocolBase=(struct Library *)OpenLibrary("xprzmodem.library",0L))) { puttekn("\r\n\nKunde inte öppna xprzmodem.library!\r\n",-1); return(2); } if(!(xio=(struct XPR_IO *)AllocMem(sizeof(struct XPR_IO),MEMF_PUBLIC | MEMF_CLEAR))) { puttekn("\r\n\nKunde inte allokera en io-struktur\r\n",-1); CloseLibrary(XProtocolBase); return(2); } puttekn("\r\nDu kan börja ta emot med Zmodem.\r\n",-1); puttekn("Tryck Ctrl-X några gånger för att avbryta.\r\n",-1); AbortIO((struct IORequest *)serreadreq); WaitIO((struct IORequest *)serreadreq); if(!CheckIO((struct IORequest *)inactivereq)) { AbortIO((struct IORequest *)inactivereq); WaitIO((struct IORequest *)inactivereq); } xpr_setup(xio); xio->xpr_filename=zinitstring; XProtocolSetup(xio); xio->xpr_filename="Hejhopp"; xprreturkod=XProtocolSend(xio); Delay(30); XProtocolCleanup(xio); CloseLibrary(XProtocolBase); if(!CheckIO((struct IORequest *)serreadreq)) { AbortIO((struct IORequest *)serreadreq); WaitIO((struct IORequest *)serreadreq); printf("Serreadreq avbruten!!\n"); } if(!CheckIO((struct IORequest *)timerreq)) { AbortIO((struct IORequest *)timerreq); WaitIO((struct IORequest *)timerreq); printf("Timerreq avbruten!!\n"); } FreeMem(xio,sizeof(struct XPR_IO)); Delay(100); serchangereq->IOSer.io_Command=CMD_CLEAR; DoIO((struct IORequest *)serchangereq); serchangereq->IOSer.io_Command=CMD_FLUSH; DoIO((struct IORequest *)serchangereq); serreqtkn(); updateinactive(); if(Servermem->cfg.logmask & LOG_SENDFILE) { for(tf=(struct TransferFiles *)tf_list.mlh_Head; tf->node.mln_Succ; tf=(struct TransferFiles *)tf->node.mln_Succ) if(tf->sucess) { LogEvent(USAGE_LOG, INFO, "Skickar filen %s till %s", tf->path, getusername(inloggad)); } } for(tf=(struct TransferFiles *)tf_list.mlh_Head; tf->node.mln_Succ; tf=(struct TransferFiles *)tf->node.mln_Succ) if(tf->sucess) cnt++; if(cnt==1) strcpy(outbuffer,"\n\n\rFörde över 1 fil.\n\n\r"); else sprintf(outbuffer,"\n\n\rFörde över %d filer.\n\n\r",cnt); puttekn(outbuffer,-1); return(0); }
int recbinfile(char *dir) { int xprreturkod,bytesfree; char zmodeminit[100]; struct InfoData *id; BPTR lock; ulfiles = 0; if(access(dir,0)) { puttekn("\r\nDirectoryt finns inte!\r\n",-1); return(2); } if(!(id=AllocMem(sizeof(struct InfoData),MEMF_CLEAR))) { puttekn("\r\nKunde inte allokera en InfoData-struktur!\r\n",-1); return(2); } if(!(lock=Lock(dir,ACCESS_READ))) { puttekn("\r\nKunde inte få ett Lock för directoryt!\r\n",-1); FreeMem(id,sizeof(struct InfoData)); return(2); } if(!Info(lock,id)) { puttekn("\r\nKunde inte få info om devicet!\r\n",-1); UnLock(lock); FreeMem(id,sizeof(struct InfoData)); return(2); } bytesfree=(id->id_NumBlocks - id->id_NumBlocksUsed)*id->id_BytesPerBlock; UnLock(lock); FreeMem(id,sizeof(struct InfoData)); if(bytesfree < Servermem->cfg.diskfree) { puttekn("\r\nTyvärr, gränsen för hur full disken får bli har överskridits!\r\n",-1); return(2); } if(Servermem->cfg.ar.preup2) sendrexx(Servermem->cfg.ar.preup2); sprintf(zmodeminit,"%s%s",zinitstring,dir); if(!(XProtocolBase=(struct Library *)OpenLibrary("xprzmodem.library",0L))) { puttekn("\r\n\nKunde inte öppna xprzmodem.library!\r\n",-1); return(2); } if(!(xio=(struct XPR_IO *)AllocMem(sizeof(struct XPR_IO),MEMF_PUBLIC | MEMF_CLEAR))) { puttekn("\r\n\nKunde inte allokera en io-struktur\r\n",-1); CloseLibrary(XProtocolBase); return(2); } NewList((struct List *)&tf_list); puttekn("\r\nDu kan börja sända med Zmodem. Du kan nu skicka fler filer!",-1); puttekn("\r\nTryck Ctrl-X några gånger för att avbryta.\r\n",-1); AbortIO((struct IORequest *)serreadreq); WaitIO((struct IORequest *)serreadreq); if(!CheckIO((struct IORequest *)inactivereq)) { AbortIO((struct IORequest *)inactivereq); WaitIO((struct IORequest *)inactivereq); } xpr_setup(xio); xio->xpr_filename=zmodeminit; XProtocolSetup(xio); xprreturkod=XProtocolReceive(xio); Delay(30); XProtocolCleanup(xio); CloseLibrary(XProtocolBase); if(!CheckIO((struct IORequest *)serreadreq)) { AbortIO((struct IORequest *)serreadreq); WaitIO((struct IORequest *)serreadreq); printf("Serreadreq avbruten!!\n"); } if(!CheckIO((struct IORequest *)timerreq)) { AbortIO((struct IORequest *)timerreq); WaitIO((struct IORequest *)timerreq); printf("Timerreq avbruten!!\n"); } FreeMem(xio,sizeof(struct XPR_IO)); Delay(100); serchangereq->IOSer.io_Command=CMD_CLEAR; DoIO((struct IORequest *)serchangereq); serchangereq->IOSer.io_Command=CMD_FLUSH; DoIO((struct IORequest *)serchangereq); serreqtkn(); updateinactive(); if(Servermem->cfg.ar.postup2) sendrexx(Servermem->cfg.ar.postup2); /* if(Servermem->cfg.logmask & LOG_RECFILE) { sprintf(outbuffer,"Tar emot filen %s från %s",xprfilnamn,getusername(inloggad)); logevent(outbuffer); } if(xprreturkod) { puttekn("\r\n\nÖverföringen lyckades.\r\n",-1); sprintf(outbuffer,"Hastighet: %d cps\n\r",cps); puttekn(outbuffer,-1); return(0); } else { puttekn("\r\n\nÖverföringen misslyckades.\r\n",-1); return(2); } Removed by Tomas Kärki 22/1 1996 */ if(ulfiles > 0) { puttekn("\r\n\nÖverföringen lyckades.\r\n",-1); return(0); } else { puttekn("\r\n\nÖverföringen misslyckades.\r\n",-1); return(2); } }
int recbinfile(char *dir) { int xprreturkod; char zmodeminit[100]; ulfiles = 0; if(access(dir,0)) { puttekn("\r\nDirectoryt finns inte!\r\n",-1); return 2; } if(Servermem->cfg.diskfree != 0 && !HasPartitionEnoughFreeSpace(dir, Servermem->cfg.diskfree)) { puttekn("\r\nTyvärr, gränsen för hur full disken får bli har överskridits!\r\n",-1); return 2; } if(Servermem->cfg.ar.preup2) { sendautorexx(Servermem->cfg.ar.preup2); } sprintf(zmodeminit,"%s%s",zinitstring,dir); if(!(XProtocolBase = (struct Library *) OpenLibrary("xprzmodem.library", 0L))) { puttekn("\r\n\nKunde inte öppna xprzmodem.library!\r\n",-1); return 2; } if(!(xio = (struct XPR_IO *) AllocMem(sizeof(struct XPR_IO), MEMF_PUBLIC | MEMF_CLEAR))) { puttekn("\r\n\nKunde inte allokera en io-struktur\r\n",-1); CloseLibrary(XProtocolBase); return 2; } NewList((struct List *)&tf_list); puttekn("\r\nDu kan börja sända med Zmodem. Du kan nu skicka fler filer!",-1); puttekn("\r\nTryck Ctrl-X några gånger för att avbryta.\r\n",-1); AbortIO((struct IORequest *)serreadreq); WaitIO((struct IORequest *)serreadreq); if(!CheckIO((struct IORequest *)inactivereq)) { AbortIO((struct IORequest *)inactivereq); WaitIO((struct IORequest *)inactivereq); } xpr_setup(xio); xio->xpr_filename = zmodeminit; XProtocolSetup(xio); xprreturkod = XProtocolReceive(xio); Delay(30); XProtocolCleanup(xio); CloseLibrary(XProtocolBase); if(!CheckIO((struct IORequest *)serreadreq)) { AbortIO((struct IORequest *)serreadreq); WaitIO((struct IORequest *)serreadreq); printf("Serreadreq avbruten!!\n"); } if(!CheckIO((struct IORequest *)timerreq)) { AbortIO((struct IORequest *)timerreq); WaitIO((struct IORequest *)timerreq); printf("Timerreq avbruten!!\n"); } FreeMem(xio,sizeof(struct XPR_IO)); Delay(100); serchangereq->IOSer.io_Command=CMD_CLEAR; DoIO((struct IORequest *)serchangereq); serchangereq->IOSer.io_Command=CMD_FLUSH; DoIO((struct IORequest *)serchangereq); serreqtkn(); updateinactive(); if(Servermem->cfg.ar.postup2) { sendautorexx(Servermem->cfg.ar.postup2); } if(ulfiles > 0) { puttekn("\r\n\nÖverföringen lyckades.\r\n",-1); return 0; } else { puttekn("\r\n\nÖverföringen misslyckades.\r\n",-1); return 2; } }
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,""); }