Exemple #1
0
int skrivlapp(void) {
	int editret;
	struct EditLine *el;
	FILE *fp;
	char filnamn[100];
	sprintf(filnamn,"NiKom:Users/%d/%d/Lapp",inloggad/100,inloggad);
	puttekn("\r\n\nGår in i editorn.\r\n",-1);
	if((editret=edittext(filnamn))==1) return(1);
	else if(editret==2) return(0);
	if(!(fp=fopen(filnamn,"w"))) {
		puttekn("\r\nKunde inte spara lappen\r\n\n",-1);
		return(0);
	}
	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)) {
			sprintf(outbuffer,"\r\n\nFel vid skrivandet av %s!\r\n",filnamn);
			puttekn(outbuffer,-1);
			fclose(fp);
			return(0);
		}
		fputc('\n',fp);
	}
	fclose(fp);
	freeeditlist();
}
Exemple #2
0
void rxedit(struct RexxMsg *mess) {
        int editret,cnt,len;
        char *filnamn,retstr[2];
        BPTR fh;
        struct EditLine *el;
        nu_skrivs=ANNAT;
        filnamn=hittaefter(mess->rm_Args[0]);
        if(!filnamn[0]) {
                mess->rm_Result1=5;
                mess->rm_Result2=NULL;
                return;
        }
/*      puttekn("\r\n\n",-1); Detta måste nu fixas i ARexx-programmet
		istället */

        if((editret=edittext(filnamn))==1) {
                mess->rm_Result1=100;
                mess->rm_Result2=NULL;
                return;
        } else if(editret==0) {
                if(!(fh=Open(filnamn,MODE_NEWFILE))) {
                        sprintf(outbuffer,"\r\n\nKunde inte öppna %s för skrivning!\r\n");
                        puttekn(outbuffer,-1);
                        mess->rm_Result1=5;
                        mess->rm_Result2=NULL;
                        return;
                }
                cnt=0;
                for(el=(struct EditLine *)edit_list.mlh_Head;el->line_node.mln_Succ;el=(struct EditLine *)el->line_node.mln_Succ) {
                        len=strlen(el->text);
                        el->text[len]='\n';
                        if(Write(fh,el->text,len+1)==-1) {
                                sprintf(outbuffer,"\r\n\nFel vid skrivandet av %s!\r\n",filnamn);
                                puttekn(outbuffer,-1);
                                Close(fh);
                                mess->rm_Result1=5;
                                mess->rm_Result2=NULL;
                                return;
                        }
                        cnt++;
                }
                Close(fh);
                freeeditlist();
        }
        mess->rm_Result1=0;
        retstr[0]= editret ? '0' : '1';
        retstr[1]=0;
        if(mess->rm_Action & 1L<<RXFB_RESULT) {
                if(!(mess->rm_Result2=(long)CreateArgstring(retstr,1)))
                        puttekn("\r\n\nKunde inte allokera en Argstring!\r\n\n",-1);
        }
}
Exemple #3
0
void cleanup(int kod,char *fel)
{
	shutdownnode(NODCON);
	freealiasmem();
	freeeditlist();
	CloseIO();
	if(NiKwind) CloseWindow(NiKwind);
	if(RexxSysBase) CloseLibrary((struct Library *)RexxSysBase);
	if(nikomnodeport) {
		RemPort(nikomnodeport);
		DeleteMsgPort(nikomnodeport);
	}
	if(rexxport) {
		RemPort(rexxport);
		DeleteMsgPort(rexxport);
	}
	if(NiKomBase) CloseLibrary(NiKomBase);
	if(UtilityBase) CloseLibrary(UtilityBase);
	if(IntuitionBase) CloseLibrary((struct Library *)IntuitionBase);
	printf("%s",fel);
	exit(kod);
}
Exemple #4
0
void rxedit(struct RexxMsg *mess) {
  int editret, cnt, len;
  char *filename;
  BPTR fh;
  struct EditLine *el;
  nu_skrivs = ANNAT;
  filename = hittaefter(mess->rm_Args[0]);
  if(filename[0] == '\0') {
    SetRexxErrorResult(mess, 5);
    return;
  }

  if((editret = edittext(filename)) == 1) {
    SetRexxErrorResult(mess, 100);
    return;
  } else if(editret == 0) {
    if(!(fh = Open(filename, MODE_NEWFILE))) {
      LogEvent(SYSTEM_LOG, WARN,
               "Could not open '%s' for writing in ARexx 'edit'.", filename);
      SetRexxErrorResult(mess, 20);
      return;
    }
    cnt = 0;
    ITER_EL(el, edit_list, line_node, struct EditLine *) {
      len = strlen(el->text);
      el->text[len] = '\n';
      if(Write(fh, el->text, len + 1) == -1) {
        LogEvent(SYSTEM_LOG, WARN,
                 "Error writing '%s' in ARexx 'edit'.", filename);
        Close(fh);
        SetRexxErrorResult(mess, 20);
        return;
      }
      cnt++;
    }
    Close(fh);
    freeeditlist();
  }
Exemple #5
0
void Cmd_FootNote(void) {
  int textId, confId, editRet;
  struct Header textHeader;

  if(argument[0] == '\0') {
    SendString("\n\n\rSkriv: Fotnot <text nummer>\n\r");
    return;
  }
  textId = atoi(argument);
  confId = GetConferenceForText(textId);
  if(confId == -1) {
    SendString("\n\n\rFinns ingen sådan text.\n\r");
    return;
  }
  if(readtexthead(textId,&textHeader)) {
    return;
  }
  if(textHeader.person != inloggad
     && !MayAdminConf(confId, inloggad, &Servermem->inne[nodnr])) {
    SendString("\r\n\nDu kan bara lägga till fotnoter på dina egna texter.\r\n\n");
    return;
  }
  if(textHeader.footNote != 0) {
    SendString("\n\n\rTexten har redan en fotnot.\n\r");
    return;
  }

  SendString("\n\n\rFotnot till text %d av %s\n\r",
             textId, getusername(textHeader.person));
  if((editRet = edittext(NULL)) != 0) {
    return;
  }

  if(saveFootNoteLines(textId, &textHeader)) {
    writetexthead(textId, &textHeader);
  }
  freeeditlist();
}
Exemple #6
0
void cleanup(int kod,char *text) {
  CloseCatalog(g_Catalog);
	freealiasmem();
	freeeditlist();
	CloseIO();
	if(NiKwind) CloseWindow(NiKwind);
	if(RexxSysBase) CloseLibrary((struct Library *)RexxSysBase);
	if(nikomnodeport) {
		RemPort(nikomnodeport);
		DeleteMsgPort(nikomnodeport);
	}
	if(rexxport) {
		RemPort(rexxport);
		DeleteMsgPort(rexxport);
	}
	shutdownnode(NODSPAWNED);
	if(NiKomBase) CloseLibrary(NiKomBase);
	if(UtilityBase) CloseLibrary(UtilityBase);
	if(LocaleBase) CloseLibrary(LocaleBase);
	if(IntuitionBase) CloseLibrary((struct Library *)IntuitionBase);
	printf("%s",text);
	exit(kod);
}
Exemple #7
0
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);
}
Exemple #8
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);
}