Exemplo n.º 1
0
void rexxyesno(struct RexxMsg *mess)
{
        char foo[2],ja,nej,def,*pek;
        pek=hittaefter(mess->rm_Args[0]);
        if(!pek[0]) {
                ja='j'; nej='n'; def=1;
        } else {
                ja=pek[0];
                pek=hittaefter(pek);
                if(!pek[0]) {
                        nej='n'; def=1;
                } else {
                        nej=pek[0];
                        pek=hittaefter(pek);
                        if(!pek[0]) def=1;
                        else def=pek[0]-'0';
                }
        }
        foo[0]=jaellernej(ja,nej,def)+'0';
        foo[1]=0;
        if(carrierdropped()) {
                mess->rm_Result1=100;
                return;
        }
        mess->rm_Result1=0;
        if(mess->rm_Action & 1L<<RXFB_RESULT) {
                if(!(mess->rm_Result2=(long)CreateArgstring(foo,1)))
                        puttekn("\r\n\nKunde inte allokera en Argstring!\r\n\n",-1);
        }
}
Exemplo n.º 2
0
long __saveds __regargs nik_swrite(char *databuffer,long size) {
    serwritereq->IOSer.io_Command=CMD_WRITE;
    serwritereq->IOSer.io_Length=size;
    serwritereq->IOSer.io_Data=(APTR)databuffer;
    if(DoIO((struct IORequest *)serwritereq) || carrierdropped()) {
        return(-1L);
    }
    return(0L);
}
Exemplo n.º 3
0
int sendtocon(char *pekare, int size)
{
	struct IntuiMessage *mymess;
	struct NiKMess *nikmess;
	int aborted = FALSE, paused=FALSE;
	ULONG signals,conwritesig = 1L << conwriteport->mp_SigBit,
		conreadsig = 1L << conreadport->mp_SigBit,windsig = 1L << NiKwind->UserPort->mp_SigBit,
		nikomnodesig = 1L << nikomnodeport->mp_SigBit;
	char console = 1, tecken;

	conwritereq->io_Command=CMD_WRITE;
	conwritereq->io_Data=(APTR)pekare;
	conwritereq->io_Length=size;
	SendIO((struct IORequest *)conwritereq);
	while(console)
	{
		signals = Wait(conwritesig | conreadsig | windsig | nikomnodesig);
		if(signals & conwritesig) {
			console=0;
			if(WaitIO((struct IORequest *)conwritereq)) printf("Error console\n");
		}
		if(signals & conreadsig) {
			if((tecken=congettkn()) == 3) {
				if(console) {
					AbortIO((struct IORequest *)conwritereq);
					WaitIO((struct IORequest *)conwritereq);
				}
				aborted=TRUE;
				console=0;
				putstring("^C\n\r",-1,0);
			} else if((tecken==' ' && (Servermem->inne[nodnr].flaggor & MELLANSLAG)) || tecken==19) paused=TRUE;
			else if(tecken && typeaheadbuftkn<50) {
				typeaheadbuf[typeaheadbuftkn++]=tecken;
				typeaheadbuf[typeaheadbuftkn]=0;
			}
		}
		if(signals & windsig) {
			mymess=(struct IntuiMessage *)GetMsg(NiKwind->UserPort);
			ReplyMsg((struct Message *)mymess);
			cleanup(OK,"");
		}
		if(signals & nikomnodesig) {
			while(nikmess = (struct NiKMess *) GetMsg(nikomnodeport)) {
				handleservermess(nikmess);
				ReplyMsg((struct Message *)nikmess);
			}
			if(carrierdropped()) aborted = TRUE;
		}
	}
	if(paused && gettekn()==3)
	{
		putstring("^C\n\r",-1,0);
		return(TRUE);
	}

	return(aborted);
}
Exemplo n.º 4
0
void rexxsendtextfile(struct RexxMsg *mess) {
  char *filename;

  filename = hittaefter(mess->rm_Args[0]);
  if(filename[0] == '\0') {
    SetRexxErrorResult(mess, 10);
    return;
  }
  sendfile(filename);
  SetRexxErrorResult(mess, carrierdropped() ? 100 : 0);
}
Exemplo n.º 5
0
int commonsendrexx(int komnr,int hasarg) {
  char rexxCmd[1081];
  struct RexxMsg *nikrexxmess, *mess;

  sendrexxrc = -5;
  if(!hasarg) {
    sprintf(rexxCmd, "NiKom:rexx/ExtKom%d %d %d", komnr, nodnr, inloggad);
  } else {
    sprintf(rexxCmd, "NiKom:rexx/ExtKom%d %d %d %s", komnr, nodnr, inloggad, argument);
  }

  if(!(nikrexxmess = (struct RexxMsg *) CreateRexxMsg(
      rexxport, "nik", rexxport->mp_Node.ln_Name))) {
    LogEvent(SYSTEM_LOG, ERROR, "Couldn't allocate a RexxMsg.");
    return -5;
  }
  if(!(nikrexxmess->rm_Args[0] =
       (STRPTR)CreateArgstring(rexxCmd,strlen(rexxCmd)))) {
    DeleteRexxMsg(nikrexxmess);
    LogEvent(SYSTEM_LOG, ERROR, "Couldn't allocate a rexx ArgString.");
    return -5;
  }

  nikrexxmess->rm_Action = RXCOMM | RXFB_TOKEN;
  if(!SafePutToPort((struct Message *)nikrexxmess, "REXX")) {
    LogEvent(SYSTEM_LOG, ERROR, "Can't launch ARexx script, REXX port not found.");
    return -5;
  }

  for(;;) {
    mess = (struct RexxMsg *)WaitPort(rexxport);
    while(mess = (struct RexxMsg *)GetMsg(rexxport)) {
      if(mess->rm_Node.mn_Node.ln_Type == NT_REPLYMSG) {
        DeleteArgstring(nikrexxmess->rm_Args[0]);
        if(nikrexxmess->rm_Result1) {
          LogEvent(SYSTEM_LOG, WARN, "Error return code %d from ARexx script: '%s'",
                   nikrexxmess->rm_Result1, rexxCmd);
          SendString("\r\n\nError executing ARexx script.\r\n\n");
        }
        DeleteRexxMsg(nikrexxmess);
        if(!rxlinecount) {
          rxlinecount=TRUE;
          radcnt = 0;
        }
        return sendrexxrc;
      }
      handleRexxCommand(mess->rm_Args[0], mess);
      ReplyMsg((struct Message *)mess);
    }
  }
  if(carrierdropped()) return(-8);
  return(sendrexxrc);
}
Exemplo n.º 6
0
void rexxsendstring(struct RexxMsg *mess) {
  char *str;
  int res;

  str = hittaefter(mess->rm_Args[0]);
  res = puttekn(str, -1);
  if(carrierdropped()) {
    SetRexxErrorResult(mess, 100);
  } else {    
    SetRexxResultString(mess, res ? "1" : "0");
  }
}
Exemplo n.º 7
0
void rxsendserchar(struct RexxMsg *mess) {
        char *arg;
        arg=hittaefter(mess->rm_Args[0]);
        if(arg[0]!='/' || arg[1]==0) {
                mess->rm_Result1=10;
                mess->rm_Result2=NULL;
                return;
        }
        sereka(arg[1]);
        if(carrierdropped()) mess->rm_Result1=100;
        else mess->rm_Result1=0;
        mess->rm_Result2=NULL;
}
Exemplo n.º 8
0
void rexxsendserstring(struct RexxMsg *mess) {
  char *str, res;
  str = hittaefter(mess->rm_Args[0]);
  if(Servermem->nodtyp[nodnr] != NODCON) {
    res = serputtekn(str, -1);
  } else {
    res = conputtekn(str, -1);
  }
  if(carrierdropped()) {
    SetRexxErrorResult(mess, 100);
  } else {    
    SetRexxResultString(mess, res ? "1" : "0");
  }
}
Exemplo n.º 9
0
void rexxgettekn(struct RexxMsg *mess) {
        UBYTE foo[2];
        foo[0]=gettekn();
        foo[1]=0;
        if(foo[0]==10 && carrierdropped()) {
                mess->rm_Result1=100;
                mess->rm_Result2=NULL;
        } else {
                mess->rm_Result1=0;
                if(mess->rm_Action & 1L<<RXFB_RESULT) {
                        if(!(mess->rm_Result2=(long)CreateArgstring(foo,1)))
                                puttekn("\r\n\nKunde inte allokera en Argstring!\r\n\n",-1);
                }
        }
}
Exemplo n.º 10
0
long __saveds __regargs nik_sread(char *databuffer,long size,long timeout) {
    ULONG signals,sersig=1L << serreadport->mp_SigBit,
                  timersig=1L << timerport->mp_SigBit;
    if(timeout) {
        serreadreq->IOSer.io_Command=CMD_READ;
        serreadreq->IOSer.io_Length=size;
        serreadreq->IOSer.io_Data=(APTR)databuffer;
        SendIO((struct IORequest *)serreadreq);
        timerreq->tr_node.io_Command=TR_ADDREQUEST;
        timerreq->tr_time.tv_secs=timeout/1000000;
        timerreq->tr_time.tv_micro=timeout%1000000;
        timerreq->tr_node.io_Message.mn_ReplyPort=timerport;
        SendIO((struct IORequest *)timerreq);
        for(;;) {
            signals=Wait(sersig | timersig);
            if((signals & sersig) && CheckIO((struct IORequest *)serreadreq)) {
                WaitIO((struct IORequest *)serreadreq);
                AbortIO((struct IORequest *)timerreq);
                WaitIO((struct IORequest *)timerreq);
                if(serreadreq->IOSer.io_Error || carrierdropped()) return(-1L);
                return((long)serreadreq->IOSer.io_Actual);
            }
            if((signals & timersig) && CheckIO((struct IORequest *)timerreq)) {
                WaitIO((struct IORequest *)timerreq);
                AbortIO((struct IORequest *)serreadreq);
                WaitIO((struct IORequest *)serreadreq);
                /* printf("Timeout! Size=%d Timeout=%d Actual=%d",size,timeout,serreadreq->IOSer.io_Actual); */
                return((long)serreadreq->IOSer.io_Actual);
            }
        }
    } else {
        serreadreq->IOSer.io_Command=SDCMD_QUERY;
        DoIO((struct IORequest *)serreadreq);
        serreadreq->IOSer.io_Command=CMD_READ;
        if(serreadreq->IOSer.io_Actual > size) serreadreq->IOSer.io_Length=size;
        else serreadreq->IOSer.io_Length=serreadreq->IOSer.io_Actual;
        serreadreq->IOSer.io_Data=(APTR)databuffer;
        DoIO((struct IORequest *)serreadreq);
        return((long)serreadreq->IOSer.io_Actual);
    }
}
Exemplo n.º 11
0
char gettekn(void)
{
	struct IntuiMessage *mymess;
	struct NiKMess *nikmess;
	ULONG signals,conreadsig=1L << conreadport->mp_SigBit,windsig=1L << NiKwind->UserPort->mp_SigBit,
		nikomnodesig = 1L << nikomnodeport->mp_SigBit;
	char tkn=0,tmp[51];
	if(typeaheadbuftkn)
	{
		tkn=typeaheadbuf[0];
		strcpy(tmp,&typeaheadbuf[1]);
		strcpy(typeaheadbuf,tmp);
		typeaheadbuftkn--;
	}
	else
	{
		while(!tkn)
		{
			signals=Wait(conreadsig | windsig | nikomnodesig);
			if(signals & conreadsig)
				tkn=congettkn();

			if(signals & windsig)
			{
				mymess=(struct IntuiMessage *)GetMsg(NiKwind->UserPort);
				ReplyMsg((struct Message *)mymess);
				cleanup(OK,"");
			}
			if(signals & nikomnodesig)
			{
				while(nikmess = (struct NiKMess *) GetMsg(nikomnodeport))
				{
					handleservermess(nikmess);
					ReplyMsg((struct Message *)nikmess);
				}
				if(carrierdropped()) tkn = '\n';
			}
		}
	}
	return(tkn);
}
Exemplo n.º 12
0
int getfifoevent(struct MsgPort *fifoport, char *puthere)
{
	struct IntuiMessage *mymess;
	struct NiKMess *nikmess;
	ULONG signals,conreadsig=1L << conreadport->mp_SigBit,windsig=1L << NiKwind->UserPort->mp_SigBit,
		fifosig=1L << fifoport->mp_SigBit, nikomnodesig = 1L << nikomnodeport->mp_SigBit;
	int event=0;
	while(!event) {
		signals = Wait(conreadsig | windsig | fifosig | nikomnodesig | SIGBREAKF_CTRL_C);
		if((signals & conreadsig) && CheckIO((struct IORequest *)conreadreq)) {
			*puthere=congettkn();
			event|=FIFOEVENT_FROMUSER;
		}
		if(signals & windsig) {
			mymess=(struct IntuiMessage *)GetMsg(NiKwind->UserPort);
			ReplyMsg((struct Message *)mymess);
			AbortIO((struct IORequest *)conreadreq);
			WaitIO((struct IORequest *)conreadreq);
			event|=FIFOEVENT_CLOSEW;
		}
		if(signals & SIGBREAKF_CTRL_C) {
			AbortIO((struct IORequest *)conreadreq);
			WaitIO((struct IORequest *)conreadreq);
			event|=FIFOEVENT_CLOSEW;
		}
		if(signals & fifosig) {
			event|=FIFOEVENT_FROMFIFO;
		}
		if(signals & nikomnodesig) {
			while(nikmess = (struct NiKMess *) GetMsg(nikomnodeport)) {
				handleservermess(nikmess);
				ReplyMsg((struct Message *)nikmess);
			}
			if(carrierdropped()) event |= FIFOEVENT_NOCARRIER;
		}
	}
	return(event);
}
Exemplo n.º 13
0
int commonsendrexx(int komnr,int hasarg) {
        char macronamn[1081],*rexxargs1;
        int going = TRUE;
        struct RexxMsg *nikrexxmess,*tempmess;
        struct MsgPort *rexxmastport;

        sendrexxrc=-5;
        if(!hasarg)
                sprintf(macronamn,"NiKom:rexx/ExtKom%d %d %d",komnr,nodnr,inloggad);
        else
                sprintf(macronamn,"NiKom:rexx/ExtKom%d %d %d %s",komnr,nodnr,inloggad,argument);

        if(!(nikrexxmess=(struct RexxMsg *)CreateRexxMsg(rexxport,"nik",rexxport->mp_Node.ln_Name))) {
                puttekn("\r\n\nKunde inte allokera ett RexxMsg!\r\n\n",-1);
                return(-5);
        }
        if(!(nikrexxmess->rm_Args[0]=(STRPTR)CreateArgstring(macronamn,strlen(macronamn)))) {
                DeleteRexxMsg(nikrexxmess);
                puttekn("\r\n\nKunde inte allokera en ArgString1\r\n\n",-1);
                return(-5);
        }
        nikrexxmess->rm_Action=RXCOMM | RXFB_TOKEN;
        Forbid();
        if(!(rexxmastport=(struct MsgPort *)FindPort("REXX"))) {
                Permit();
                puttekn("\r\n\nRexxMast är inte igång!\r\n\n",-1);
                return(-5);
        }
        PutMsg(rexxmastport,(struct Message *)nikrexxmess);
        Permit();
        while(going) {
                tempmess = (struct RexxMsg *)WaitPort(rexxport);
                if(!tempmess) printf("*** Something's fishy around here... ***\n");
                while(tempmess=(struct RexxMsg *)GetMsg(rexxport)) {
                        if(tempmess->rm_Node.mn_Node.ln_Type==NT_REPLYMSG) {
                                DeleteArgstring(nikrexxmess->rm_Args[0]);
                                if(nikrexxmess->rm_Result1) {
                                        sprintf(outbuffer,"\r\n\nRexx: Return-code %d\r\n\n",nikrexxmess->rm_Result1);
                                        puttekn(outbuffer,-1);
                                }
                                DeleteRexxMsg(nikrexxmess);
                                if(!rxlinecount)
                                {
	                                rxlinecount=TRUE;
	                                radcnt = 0;
								}
                                return(sendrexxrc);
                        }
                        if(!strnicmp(tempmess->rm_Args[0],"sendstring",10)) rexxsendstring(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"sendserstring",13)) rexxsendserstring(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"getstring",9)) rexxgetstring(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"sendtextfile",12)) sendfile(rexxargs1=hittaefter(tempmess->rm_Args[0]));
                        else if(!strnicmp(tempmess->rm_Args[0],"showtext",8)) rxvisatext(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"showletter",10)) rexxvisabrev(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"lasttext",8)) senastread(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"nikcommand",10)) kommando(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"niknrcommand",12)) niknrcommand(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"edit",4)) rxedit(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"sendbinfile",11)) rexxsendbinfile(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"recbinfile",10)) rexxrecbinfile(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"getchar",7)) rexxgettekn(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"chkbuffer",9)) rexxchkbuffer(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"yesno",5)) rexxyesno(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"whicharea",9)) whicharea(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"whichmeet",9)) whichmeet(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"logout",6)) rxlogout(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"runfifo",7)) rxrunfifo(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"runrawfifo",10)) rxrunrawfifo(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"entermeet",9)) rxentermeet(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"setlinecount",12)) rxsetlinecount(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"extratime",9)) rxextratime(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"gettime",7)) rxgettime(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"sendchar",8)) rxsendchar(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"sendserchar",11)) rxsendserchar(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"setnodeaction",13)) rxsetnodeaction(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"sendrawfile",11)) rxsendrawfile(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"changelatestinfo",16)) rxchglatestinfo(tempmess);
                        else if(!strnicmp(tempmess->rm_Args[0],"getnumber",9)) rxgetnumber(tempmess);
                        else {
                                sprintf(outbuffer,"\r\n\nKan inte hantera: %s\r\n",tempmess->rm_Args[0]);
                                puttekn(outbuffer,-1);
                                tempmess->rm_Result1=5;
                                tempmess->rm_Result2=NULL;
                        }
                        ReplyMsg((struct Message *)tempmess);
                }
        }
        if(carrierdropped()) return(-8);
        return(sendrexxrc);
}
Exemplo n.º 14
0
int upload(void) {	/* Ändrad för nikfiles.data 960707 JÖ */
    int area,ret,editret,dirnr;
    long tid;
    struct EditLine *el;
    FILE *fp;
    __aligned struct FileInfoBlock info;
    struct Fil *allokpek;
    char nikfilename[100],errbuff[100],filnamn[50],tmpfullname[100], outbuffer[81];
    UBYTE tn;
    struct TransferFiles *tf;

    if(Servermem->cfg.ar.preup1) sendautorexx(Servermem->cfg.ar.preup1);
    if(area2==-1) {
        puttekn("\r\nI vilken area? ",-1);
    } else {
        sprintf(outbuffer,"\r\nI vilken area? (<RETURN> för %s)",Servermem->areor[area2].namn);
        puttekn(outbuffer,-1);
    }
    if(getstring(EKO,40,NULL)) return(1);
    if((area=parsearea(inmat))==-1) {
        puttekn("\n\rFinns ingen sådan area!\n\r",-1);
        return(0);
    } else if(area==-3) {
        if(area2==-1) return(0);
        area=area2;
    }
    if(!arearatt(area, inloggad, &Servermem->inne[nodnr])) {
        puttekn("\n\rFinns ingen sådan area!\n\r",-1);
        return(0);
    }
    if((Servermem->areor[area].flaggor & AREA_NOUPLOAD) && (Servermem->inne[nodnr].status < Servermem->cfg.st.laddaner)) {
        puttekn("\n\n\rDu har ingen rätt att ladda upp till den arean!\n\r",-1);
        return(0);
    }
    Servermem->action[nodnr] = UPLOAD;
    Servermem->varmote[nodnr] = area;
    Servermem->vilkastr[nodnr] = NULL;
    if(ret=recbinfile(Servermem->cfg.ultmp)) {
        while(tf=(struct TransferFiles *)RemHead((struct List *)&tf_list))
            FreeMem(tf,sizeof(struct TransferFiles));
        if(carrierdropped()) return(1);
        return(0);
    }

    /* printf("Filnamn = %s\n",FilePart(tf->Filnamn));
    printf("Cps = %d\n\n",tf->cps); */

    for(tf=(struct TransferFiles *)tf_list.mlh_Head; tf->node.mln_Succ; tf=(struct TransferFiles *)tf->node.mln_Succ) {
        strcpy(xprfilnamn,tf->Filnamn);
        if(stcgfn(filnamn,xprfilnamn)>40) puttekn("\r\nVARNING! Filnamnet större än 40 tecken!\r\n",-1);
        if(!filnamn[0]) {
            puttekn("\r\n\nHmm... Filen har inget namn. Skriv ett brev till sysop.\r\n",-1);
            continue;
        }
        if(!valnamn(filnamn,area,errbuff)) {
            for(;;) {
                puttekn(errbuff,-1);
                puttekn("\r\nNytt namn: ",-1);
                if(getstring(EKO,40,NULL)) {
                    DeleteFile(xprfilnamn);
                    return(1);
                }
                if(!inmat[0]) continue;
                if(valnamn(inmat,area,errbuff)) break;
            }
            strcpy(filnamn,inmat);
            sprintf(tmpfullname,"%s%s",Servermem->cfg.ultmp,filnamn);
            if(!Rename(xprfilnamn,tmpfullname)) {
                sprintf(outbuffer,"\r\n\nKunde inte döpa om filen från '%s'\r\ntill '%s'.\r\n",xprfilnamn,tmpfullname);
                puttekn(outbuffer,-1);
                DeleteFile(xprfilnamn);
                continue;
            }
        } else strcpy(tmpfullname,xprfilnamn);
        if(!(allokpek=(struct Fil *)AllocMem(sizeof(struct Fil),MEMF_PUBLIC | MEMF_CLEAR))) {
            puttekn("\r\n\nKunde inte allokera minne för filen!\r\n",-1);
            continue;
        }
        time(&tid);
        allokpek->tid=allokpek->validtime=tid;
        allokpek->uppladdare=inloggad;
        if(dfind(&info,tmpfullname,0)) {
            sprintf(outbuffer,"\r\nHittar inte filen %s!\r\n",tmpfullname);
            puttekn(outbuffer,-1);
            FreeMem(allokpek,sizeof(struct Fil));
            continue;
        }
        allokpek->size=info.fib_Size;

        sprintf(outbuffer,"\r\n\r\nFilnamn: %s", filnamn);
        puttekn(outbuffer,-1);
        puttekn("\r\nVilken status ska behövas för att ladda ner filen? (0)",-1);
        if(getstring(EKO,3,NULL)) {
            FreeMem(allokpek,sizeof(struct Fil));
            return(1);
        }
        allokpek->status=atoi(inmat);
        if(Servermem->inne[nodnr].status >= Servermem->cfg.st.filer) {
            puttekn("\n\rSka filen valideras? ",-1);
            if(jaellernej('j','n',1)) puttekn("Ja",-1);
            else {
                puttekn("Nej",-1);
                allokpek->flaggor|=FILE_NOTVALID;
            }
            puttekn("\n\rSka filen ha fri download? ",-1);
            if(jaellernej('j','n',2)) {
                puttekn("Ja",-1);
                allokpek->flaggor|=FILE_FREEDL;
            } else puttekn("Nej",-1);
        } else if(Servermem->cfg.cfgflags & NICFG_VALIDATEFILES) allokpek->flaggor|=FILE_NOTVALID;
        sendfile("NiKom:Texter/Nyckelhjälp.txt");
        puttekn("\r\nVilka söknycklar ska filen ha? (? för att få en lista)\r\n",-1);
        if(editkey(allokpek->nycklar)) {
            FreeMem(allokpek,sizeof(struct Fil));
            return(1);
        }
        puttekn("\r\nBeskrivning:\r\n",-1);
        if(getstring(EKO,70,NULL)) {
            FreeMem(allokpek,sizeof(struct Fil));
            return(1);
        }
        strcpy(allokpek->beskr,inmat);
        dirnr = ChooseDirectoryInFileArea(
                    area, allokpek->nycklar, allokpek->size);
        if(dirnr==-1) {
            puttekn("\r\n\nKunde inte hitta något lämpligt directory för filen!\r\n",-1);
            DeleteFile(tmpfullname);
            FreeMem(allokpek,sizeof(struct Fil));
            continue;
        }
        allokpek->dir=dirnr;
        strcpy(allokpek->namn,filnamn);
        sprintf(inmat,"%s %s",tmpfullname,Servermem->areor[area].dir[dirnr]);
        argument=inmat;
        sendrexx(10);
        AddTail((struct List *)&Servermem->areor[area].ar_list,(struct Node *)allokpek);
        if(writefiles(area)) {
            puttekn("\r\n\nKunde inte skriva till datafilen\r\n",-1);

        }

        Servermem->inne[nodnr].upload++;
        Statstr.ul++;
        if(Servermem->cfg.logmask & LOG_UPLOAD) {
            LogEvent(USAGE_LOG, INFO, "%s laddar upp %s",
                     getusername(inloggad), allokpek->namn);
        }
        if(Servermem->cfg.ar.postup1) sendautorexx(Servermem->cfg.ar.postup1);
        puttekn("\r\n\nVill du skriva en längre beskrivning? (J/n) ",-1);
        while((tn=gettekn())!='j' && tn!='J' && tn!='n' && tn!='N' && tn!=13);
        if(tn=='j' || tn=='J') {
            puttekn("\r\n\nOk, går in i editorn.\r\n",-1);
            if((editret=edittext(NULL))==1) return(1);
            else if(editret==2) continue;
            sprintf(nikfilename,"%slongdesc/%s.long",Servermem->areor[area].dir[dirnr],filnamn);
            if(!(fp=fopen(nikfilename,"w"))) {
                puttekn("\r\n\nKunde inte öppna longdesc-filen\r\n",-1);
                freeeditlist();
                continue;
            }
            for(el=(struct EditLine *)edit_list.mlh_Head; el->line_node.mln_Succ; el=(struct EditLine *)el->line_node.mln_Succ) {
                if(fputs(el->text,fp)) {
                    freeeditlist();
                    fclose(fp);
                    continue;
                }
                fputc('\n',fp);
            }
            freeeditlist();
            fclose(fp);
            puttekn("\r\n",-1);
            allokpek->flaggor|=FILE_LONGDESC;
            updatefile(area,allokpek);
        }
    }

    while(tf=(struct TransferFiles *)RemHead((struct List *)&tf_list))
        FreeMem(tf,sizeof(struct TransferFiles));

    return(0);
}
Exemplo n.º 15
0
int download(void) {
    int cnt,freedlonly=FALSE, global = 0, matchall = 0;
    char *nextfile,*nextnext;
    struct Fil *filpek;
    struct TransferFiles *tf;
    if(Servermem->inne[nodnr].upload+1==0) {
        puttekn("\r\n\nVARNING!! Uploads = -1",-1);
        return(0);
    }
    if(Servermem->cfg.uldlratio[Servermem->inne[nodnr].status] && Servermem->cfg.uldlratio[Servermem->inne[nodnr].status] < (Servermem->inne[nodnr].download+1)/(Servermem->inne[nodnr].upload+1)) {
        sprintf(outbuffer,"\r\n\nDu måste ladda upp en fil per %d filer du laddar ner.\r\n",Servermem->cfg.uldlratio[Servermem->inne[nodnr].status]);
        puttekn(outbuffer,-1);
        puttekn("Endast filer med fri download tillåts.\n\r",-1);
        freedlonly=TRUE;
    }
    if(area2==-1) {
        puttekn("\r\n\nDu befinner dig inte i någon area!\r\n",-1);
        return(0);
    }
    if((!global && Servermem->areor[area2].flaggor & AREA_NODOWNLOAD) && (Servermem->inne[nodnr].status < Servermem->cfg.st.laddaner)) {
        puttekn("\n\n\rDu har ingen rätt att ladda ner från den här arean!\n\r",-1);
        return(0);
    }
    if(!argument[0]) {
        puttekn("\r\n\nSkriv: Download <filnamn> [<filnamn> [<filnamn> [...]]]\r\n",-1);
        return(0);
    }
    nextfile=argument;
    if(nextfile[0] == '-')
    {
        puttekn("\r\n\nTest\r\n",-1);
        if(nextfile[1] == 'g' || nextfile[1] == 'G')
            global = 1;

        if(nextfile[1] == 'a' || nextfile[1] == 'A')
            matchall = 1;

        if(!global && !matchall)
        {
            puttekn("\r\n\nOkänd option, bara -A eller -G stödjs.\r\n",-1);
            return(0);
        }

        nextfile=hittaefter(nextfile);
    }

    nextnext=hittaefter(nextfile);
    puttekn("\n\n\r",-1);
    NewList((struct List *)&tf_list);
    while(nextfile[0])
    {
        for(cnt=0; nextfile[cnt]!=' ' && nextfile[cnt]!=0; cnt++);
        nextfile[cnt]=0;
        if(!global && !(filpek=parsefil(nextfile,area2))) {
            sprintf(outbuffer,"Finns ingen fil som matchar \"%s\"\n\r",nextfile);
            puttekn(outbuffer,-1);
            nextfile=nextnext;
            nextnext=hittaefter(nextnext);
            continue;
        }
        if(!filpek && global && !(filpek=parsefilallareas(nextfile)))
        {
            sprintf(outbuffer,"Finns ingen fil som matchar \"%s\"\n\r",nextfile);
            puttekn(outbuffer,-1);
            nextfile=nextnext;
            nextnext=hittaefter(nextnext);
            continue;
        }

        if(filpek->status>Servermem->inne[nodnr].status && Servermem->inne[nodnr].status<Servermem->cfg.st.laddaner)
        {
            sprintf(outbuffer,"Du har ingen rätt att ladda ner %s!\n\r",filpek->namn);
            puttekn(outbuffer,-1);
            nextfile=nextnext;
            nextnext=hittaefter(nextnext);
            continue;
        }
        if(freedlonly && !(filpek->flaggor & FILE_FREEDL))
        {
            nextfile=nextnext;
            nextnext=hittaefter(nextnext);
            continue;
        }
        if(!(tf=(struct TransferFiles *)AllocMem(sizeof(struct TransferFiles),MEMF_CLEAR))) {
            puttekn("Kunde inte allokera en TransferFiles-struktur\n\r",-1);
            nextfile=nextnext;
            nextnext=hittaefter(nextnext);
            continue;
        }
        sprintf(tf->path,"%s%s",Servermem->areor[area2].dir[filpek->dir],filpek->namn);
        tf->filpek=filpek;
        AddTail((struct List *)&tf_list,(struct Node *)tf);
        sprintf(outbuffer,"Skickar filen %s. Storlek: %d %s\r\n",filpek->namn,filpek->size,(filpek->flaggor & FILE_FREEDL) ? "(Fri download)" : "");
        puttekn(outbuffer,-1);
        nextfile=nextnext;
        nextnext=hittaefter(nextnext);
    }
    if(!tf_list.mlh_Head->mln_Succ) {
        puttekn("\n\rInga filer att skicka.\n\r",-1);
        return(0);
    }
    Servermem->action[nodnr] = DOWNLOAD;
    Servermem->varmote[nodnr] = area2;
    Servermem->vilkastr[nodnr] = NULL;
    sendbinfile();
    if(Servermem->cfg.logmask & LOG_DOWNLOAD) {
        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, "%s laddar ner %s (%d cps)",
                         getusername(inloggad), tf->filpek->namn, tf->cps);
            }
    }
    for(tf=(struct TransferFiles *)tf_list.mlh_Head; tf->node.mln_Succ; tf=(struct TransferFiles *)tf->node.mln_Succ) {
        if(tf->sucess) {
            if(!(tf->filpek->flaggor & FILE_FREEDL)) Servermem->inne[nodnr].download++;
            Statstr.dl++;
            raisefiledl(tf->filpek);
            sprintf(outbuffer,"%s, %d cps\n\r",tf->filpek->namn,tf->cps);
            puttekn(outbuffer,-1);
        } else {
            sprintf(outbuffer,"%s misslyckades.\n\r",tf->filpek->namn);
            puttekn(outbuffer,-1);
        }
    }
    while(tf=(struct TransferFiles *)RemHead((struct List *)&tf_list))
        FreeMem(tf,sizeof(struct TransferFiles));

    if(carrierdropped()) return(1);
    else return(0);
}
Exemplo n.º 16
0
long __saveds __regargs nik_chkabort(void) {
    if(carrierdropped()) return(-1L);
    return(0L);
}