예제 #1
0
파일: MenyBrev.c 프로젝트: dblarsson/NiKom
void savefidocopy(struct FidoText *ft,int anv) {
        struct FidoLine *fl;
        BPTR fh;
        int nummer;
        char *foo,buffer[100];
        nummer=updatenextletter(anv);
        if(nummer==-1) {
                return;
        }
        sprintf(buffer,"NiKom:Users/%d/%d/%d.letter",anv/100,anv,nummer);
        if(!(fh=Open(buffer,MODE_NEWFILE))) {
                return;
        }
        FPuts(fh,"System-ID: Fido\n");
        sprintf(buffer,"From: %s (%d:%d/%d.%d)\n",ft->fromuser,ft->fromzone,ft->fromnet,ft->fromnode,ft->frompoint);
        FPuts(fh,buffer);
        sprintf(buffer,"To: %s (%d:%d/%d.%d)\n",ft->touser,ft->tozone,ft->tonet,ft->tonode,ft->topoint);
        FPuts(fh,buffer);
        sprintf(buffer,"Date: %s\n",ft->date);
        FPuts(fh,buffer);
        foo = hittaefter(ft->subject);
        if(ft->subject[0] == 0 || (ft->subject[0] == ' ' && foo[0] == 0)) strcpy(buffer,"Subject: -\n");
        else sprintf(buffer,"Subject: %s\n",ft->subject);
        FPuts(fh,buffer);
        for(fl=(struct FidoLine *)ft->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);
        sprintf(outbuffer,"\n\n\rBrevet fick nummer %d i din brevlåda\r\n\n",nummer);
        puttekn(outbuffer,-1);
}
예제 #2
0
void ErrorF(char *Format,...)
{
	void *Data;
	struct EasyStruct EasyStruct;
	ULONG IDCMPFlags;

	Data = &Format+1L;
	if (((struct Process *)FindTask(NULL))->pr_CLI)
	{
		VPrintf(Format,Data);
		FPutC(Output(),'\n');
		Flush(Output());
	}
	else
	{
		EasyStruct.es_StructSize = sizeof(struct EasyStruct);
		EasyStruct.es_Flags = 0L;
		EasyStruct.es_Title = "Error";
		EasyStruct.es_TextFormat = Format;
		EasyStruct.es_GadgetFormat = "Ok";

		IDCMPFlags = 0L;
		EasyRequestArgs(NULL,&EasyStruct,&IDCMPFlags,Data);
	}
}
예제 #3
0
파일: file.c 프로젝트: jalkanen/ppt
void SaveConvFilter( struct PPTBase *PPTBase, char *name, struct convargs *cargs )
{
    APTR DOSBase = PPTBase->lb_DOS;
    BPTR fh;
    char buf[128];
    int i,j;

#ifdef DEBUG_MODE
    PDebug("SaveConvFilter()\n\tOpening file '%s'", name);
#endif

    fh = Open( name, MODE_NEWFILE );
    if(fh) {
#ifndef __PPC__
        sprintf(buf,"; PPT Convolution file\n; Generated by "MYNAME"\n" );
#endif
        FPuts(fh,buf);
        sprintf(buf,"%d\n%d\n%d\n",cargs->size,cargs->bias,cargs->div);
        FPuts(fh,buf);
        for(i = 0; i < 7; i++) {
            for(j = 0; j < 7; j++) {
                sprintf(buf,"%d ",cargs->weights[i][j]);
                FPuts(fh,buf);
            }
            FPutC(fh,'\n');
        }
        Close(fh);
    }
    /* BUG: Should warn! */
}
예제 #4
0
static int __putc(int c, BPTR fh)
{
    if (FPutC(fh, c) == EOF)
    {
	errno = IoErr2errno(IoErr());
	return EOF;
    }

    return c;
}
예제 #5
0
LONG dosstreamhook (struct Hook * hook, BPTR fh, ULONG * msg)
{
    LONG rc;

    switch (*msg)
    {
    case BEIO_READ:
	rc = FGetC (fh);
	break;

    case BEIO_WRITE:
	rc = FPutC (fh, ((struct BEIOM_Write *)msg)->Data);
	break;

    case BEIO_IGNORE:
	Flush (fh);

	rc = Seek (fh, ((struct BEIOM_Ignore *)msg)->Count, OFFSET_CURRENT);
	break;

    }

    return rc;
} /* dosstreamhook */
예제 #6
0
파일: MenyBrev.c 프로젝트: dblarsson/NiKom
void sparabrev(void) {
        BPTR fh,lock=NULL;
        struct EditLine *elpek;
        char bugbuf[100],orgfilename[50],*motstr;
        int till,nr,mot;
        Servermem->inne[nodnr].skrivit++;
        Servermem->info.skrivna++;
        Statstr.write++;
        till=atoi(brevspar.to);
        if((nr=updatenextletter(till))==-1) {
                freeeditlist();
                return;
        }
        sprintf(orgfilename,"NiKom:Users/%d/%d/%d.letter",till/100,till,nr);
        if(!(fh=Open(orgfilename,MODE_NEWFILE))) {
                puttekn("\n\n\rKunde inte öppna brevet\n\r",-1);
                freeeditlist();
                return;
        }
        strcpy(bugbuf,"System-ID: NiKom\n");
        FPuts(fh,bugbuf);
        sprintf(bugbuf,"From: %d\n",inloggad);
        FPuts(fh,bugbuf);
        sprintf(bugbuf,"To: %s\n",brevspar.to);
        FPuts(fh,bugbuf);
        if(brevspar.reply[0]) {
                sprintf(bugbuf,"Reply: %s\n",brevspar.reply);
                FPuts(fh,bugbuf);
        }
        sprintf(bugbuf,"Date: %s\n",brevspar.date);
        FPuts(fh,bugbuf);
        sprintf(bugbuf,"Subject: %s\n",brevspar.subject);
        FPuts(fh,bugbuf);
        for(elpek=(struct EditLine *)edit_list.mlh_Head;elpek->line_node.mln_Succ;elpek=(struct EditLine *)elpek->line_node.mln_Succ) {
                if(FPuts(fh,elpek->text)==-1) {
                        puttekn("\n\n\rFel vid skrivandet av brevet\n\r",-1);
                        break;
                }
                FPutC(fh,'\n');
        }
        Close(fh);
        freeeditlist();
        sprintf(outbuffer,"\r\nBrevet fick nummer %d hos %s\r\n",nr,getusername(till));
        puttekn(outbuffer,-1);
        if(Servermem->cfg.logmask & LOG_BREV) {
                strcpy(bugbuf,getusername(inloggad));
                sprintf(outbuffer,"%s skickar brev %d till %s",bugbuf,nr,getusername(till));
                logevent(outbuffer);
        }
        motstr=hittaefter(brevspar.to);
        if(motstr[0]) {
                if(!(lock=Lock(orgfilename,ACCESS_READ))) {
                        puttekn("\n\n\rKunde inte få ett lock för brevet\n\r",-1);
                        return;
                }
        }
        while(motstr[0]) {
                mot=atoi(motstr);
                if((nr=updatenextletter(mot))==-1) {
                        UnLock(lock);
                        return;
                }
                sprintf(bugbuf,"NiKom:Users/%d/%d/%d.letter",mot/100,mot,nr);
                if(!MakeLink(bugbuf,lock,FALSE)) {
                        puttekn("\n\n\rKunde inte skapa länk till brevet\n\r",-1);
                        UnLock(lock);
                        return;
                }
                sprintf(outbuffer,"\r\nBrevet fick nummer %d hos %s\r\n",nr,getusername(mot));
                puttekn(outbuffer,-1);
                if(Servermem->cfg.logmask & LOG_BREV) {
                        strcpy(bugbuf,getusername(inloggad));
                        sprintf(outbuffer,"%s skickar brev %d till %s",bugbuf,nr,getusername(mot));
                        logevent(outbuffer);
                }
                motstr=hittaefter(motstr);
        }
        if(lock) UnLock(lock);
}
예제 #7
0
파일: Matrix.c 프로젝트: jayminer81/NiKom
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);
}