int fido_brev(char *tillpers,char *adr,struct Mote *motpek) { int length=0,x=0,editret,chrs; struct FidoDomain *fd; struct FidoText *komft,ft; struct MinNode *first, *last; char *foo,tmpfrom[100],fullpath[100],filnamn[20],subject[80],msgid[50],tkn; if(!(Servermem->inne[nodnr].grupper & Servermem->fidodata.mailgroups) && Servermem->inne[nodnr].status < Servermem->fidodata.mailstatus) { puttekn("\n\n\rDu har ingen rätt att skicka FidoNet NetMail.\n\r",-1); return(0); } Servermem->action[nodnr] = SKRIVER; Servermem->varmote[nodnr] = -1; memset(&ft,0,sizeof(struct FidoText)); if(!tillpers) { /* Det handlar om en kommentar */ if(motpek) { /* Det är en personlig kommentar */ strcpy(fullpath,motpek->dir); sprintf(filnamn,"%d.msg",senast_text_nr - motpek->renumber_offset); AddPart(fullpath,filnamn,99); komft = ReadFidoTextTags(fullpath,RFT_HeaderOnly,TRUE,TAG_DONE); if(!komft) { puttekn("\n\n\rTexten finns inte.\n\r",-1); return(0); } strcpy(ft.touser,komft->fromuser); ft.tozone = komft->fromzone; ft.tonet = komft->fromnet; ft.tonode = komft->fromnode; ft.topoint = komft->frompoint; strcpy(subject,komft->subject); strcpy(msgid,komft->msgid); FreeFidoText(komft); } else { /* Det är en kommentar av ett brev */ strcpy(tmpfrom,brevread.from); foo=strchr(tmpfrom,'('); if(!foo) { puttekn("\n\n\rDen kommenterade texten saknar adress!\n\r",-1); return(0); } *(foo-1)='\0'; foo++; strcpy(ft.touser,tmpfrom); ft.tozone=getzone(foo); ft.tonet=getnet(foo); ft.tonode=getnode(foo); ft.topoint=getpoint(foo); strcpy(subject,brevread.subject); strcpy(msgid,brevread.messageid); } } else { /* Det är ett helt nytt brev */ strcpy(ft.touser,tillpers); sprattgok(ft.touser); ft.tozone=getzone(adr); ft.tonet=getnet(adr); ft.tonode=getnode(adr); ft.topoint=getpoint(adr); } fd = getfidodomain(0,ft.tozone); if(!fd) { puttekn("\n\n\rDu kan inte skriva brev till den zonen.\n\r",-1); return(0); } if(!tillpers && !motpek) { foo = strchr(brevread.to,'(')+1; ft.fromzone = getzone(foo); ft.fromnet = getnet(foo); ft.fromnode = getnode(foo); ft.frompoint = getpoint(foo); } else { ft.fromzone = fd->zone; ft.fromnet = fd->net; ft.fromnode = fd->node; ft.frompoint = fd->point; } ft.attribut = FIDOT_PRIVATE | FIDOT_LOCAL; makefidousername(ft.fromuser,inloggad); makefidodate(ft.date); sprintf(outbuffer,"\r\n\nMöte: %s\r\n",Servermem->cfg.brevnamn); puttekn(outbuffer,-1); sprintf(outbuffer,"Fido-nätbrev, %s\n\r",ft.date); puttekn(outbuffer,-1); sprintf(outbuffer,"Avsändare: %s (%d:%d/%d.%d)\r\n",ft.fromuser,ft.fromzone,ft.fromnet,ft.fromnode,ft.frompoint); puttekn(outbuffer,-1); sprintf(outbuffer,"Mottagare: %s (%d:%d/%d.%d)\n\r",ft.touser,ft.tozone,ft.tonet,ft.tonode,ft.topoint); puttekn(outbuffer,-1); puttekn("Ärende: ",-1); if(!tillpers) { if(!strncmp(subject,"Re:",3)) strcpy(ft.subject,subject); else sprintf(ft.subject,"Re: %s",subject); puttekn(ft.subject,-1); } else { if(getstring(EKO,40,NULL)) return(1); if(!inmat[0]) { eka('\n'); return(0); } strcpy(ft.subject,inmat); } puttekn("\r\n",-1); if(Servermem->inne[nodnr].flaggor & STRECKRAD) { length=strlen(ft.subject); for(x=0;x<length+8;x++) outbuffer[x]='-'; outbuffer[x]=0; puttekn(outbuffer,-1); puttekn("\r\n\n",-1); } else puttekn("\n",-1); crashmail = FALSE; editret = edittext(NULL); if(editret==1) return(1); if(editret==2) return(0); if(crashmail) ft.attribut |= FIDOT_CRASH; Servermem->inne[nodnr].skrivit++; Servermem->info.skrivna++; Statstr.write++; puttekn("\n\n\rTill vilken teckenuppsättning ska brevet konverteras?\r\n\n",-1); puttekn("1: ISO Latin 8-bitars tecken (Default)\n\r",-1); puttekn("2: IBM PC 8-bitars tecken\r\n",-1); puttekn("3: Macintosh 8-bitars tecken\r\n",-1); puttekn("4: Svenska 7-bitars tecken\r\n\n",-1); puttekn("Val: ",-1); for(;;) { tkn=gettekn(); if(tkn==13 || tkn==10) tkn='1'; if(tkn >= '1' && tkn <= '4') break; } sprintf(outbuffer,"%c\r\n\n",tkn); puttekn(outbuffer,-1); switch(tkn) { case '1' : chrs=CHRS_LATIN1; break; case '2' : chrs=CHRS_CP437; break; case '3' : chrs=CHRS_MAC; break; case '4' : chrs=CHRS_SIS7; break; } NewList((struct List *)&ft.text); first = edit_list.mlh_Head; last = edit_list.mlh_TailPred; ft.text.mlh_Head = first; ft.text.mlh_TailPred = last; last->mln_Succ = (struct MinNode *)&ft.text.mlh_Tail; first->mln_Pred = (struct MinNode *)&ft.text; if(tillpers) x = WriteFidoTextTags(&ft,WFT_MailDir,Servermem->fidodata.matrixdir, WFT_Domain,fd->domain, WFT_CharSet,chrs, TAG_DONE); else x = WriteFidoTextTags(&ft,WFT_MailDir,Servermem->fidodata.matrixdir, WFT_Domain,fd->domain, WFT_Reply,msgid, WFT_CharSet,chrs, TAG_DONE); sprintf(outbuffer,"Brevet fick nummer %d\r\n\n",x); puttekn(outbuffer,-1); if(Servermem->cfg.logmask & LOG_BREV) { strcpy(tmpfrom,getusername(inloggad)); sprintf(outbuffer,"%s skickar brev %d till %s (%d:%d/%d.%d)",tmpfrom,x,ft.touser,ft.tozone,ft.tonet,ft.tonode,ft.topoint); logevent(outbuffer); } puttekn("Vill du ha en kopia av brevet i din egen brevlåda? ",-1); if(jaellernej('j','n',2)) savefidocopy(&ft,inloggad); while(first=(struct MinNode *)RemHead((struct List *)&ft.text)) FreeMem(first,sizeof(struct EditLine)); NewList((struct List *)&edit_list); return(0); }
void __saveds __asm LIBMatrix2NiKom(register __a6 struct NiKomBase *NiKomBase) { struct FidoText *fidotext; struct FidoLine *fl; int going=TRUE,anv,brev; BPTR fh; char buffer[100],*foo,filnamn[20]; struct TagItem ti = { TAG_DONE }; if(!NiKomBase->Servermem) return; LIBLockNiKomBase(NiKomBase); while(going) { strcpy(buffer,NiKomBase->Servermem->fidodata.matrixdir); sprintf(filnamn,"%d.msg",NiKomBase->lastmatrix); AddPart(buffer,filnamn,99); if(!(fidotext = LIBReadFidoText(buffer,&ti,NiKomBase))) break; NiKomBase->lastmatrix++; if(fidotext->attribut & FIDOT_LOCAL) { continue; } sprintf(buffer,"Brev %d till %s (%d:%d/%d.%d)",NiKomBase->lastmatrix-1,fidotext->touser,fidotext->tozone,fidotext->tonet, fidotext->tonode,fidotext->topoint); writelog(NiKomBase->Servermem->fidodata.fidologfile,buffer); anv=fidoparsenamn(fidotext->touser,NiKomBase->Servermem); if(anv==-1) { sprintf(buffer,"Hittar inte %s",fidotext->touser); writelog(NiKomBase->Servermem->fidodata.fidologfile,buffer); continue; } brev=updatenextletter(anv); if(brev==-1) { continue; } sprintf(buffer,"NiKom:Users/%d/%d/%d.letter",anv/100,anv,brev); if(!(fh=Open(buffer,MODE_NEWFILE))) { continue; } FPuts(fh,"System-ID: Fido\n"); sprintf(buffer,"From: %s (%d:%d/%d.%d)\n",fidotext->fromuser,fidotext->fromzone,fidotext->fromnet, fidotext->fromnode,fidotext->frompoint); FPuts(fh,buffer); sprintf(buffer,"To: %s (%d:%d/%d.%d)\n",fidotext->touser,fidotext->tozone,fidotext->tonet, fidotext->tonode,fidotext->topoint); FPuts(fh,buffer); sprintf(buffer,"Message-ID: %s\n",fidotext->msgid); FPuts(fh,buffer); sprintf(buffer,"Date: %s\n",fidotext->date); FPuts(fh,buffer); foo = hittaefter(fidotext->subject); if(fidotext->subject[0] == 0 || (fidotext->subject[0] == ' ' && foo[0] == 0)) strcpy(buffer,"Subject: -\n"); else sprintf(buffer,"Subject: %s\n",fidotext->subject); FPuts(fh,buffer); for(fl=(struct FidoLine *)fidotext->text.mlh_Head;fl->line_node.mln_Succ;fl=(struct FidoLine *)fl->line_node.mln_Succ) { FPuts(fh,fl->text); FPutC(fh,'\n'); } Close(fh); FreeFidoText(fidotext); } sprintf(buffer,"%d",NiKomBase->lastmatrix); SetVar("NiKom:DatoCfg/LastMatrix",buffer,-1,GVF_GLOBAL_ONLY); LIBUnLockNiKomBase(NiKomBase); }