Ejemplo n.º 1
0
int parsemot(char *skri) {
    struct Mote *motpek=(struct Mote *)Servermem->mot_list.mlh_Head;
    int going2=TRUE,found=-1;
    char *faci,*skri2;
    if(skri[0]==0 || skri[0]==' ') return(-3);
    for(; motpek->mot_node.mln_Succ; motpek=(struct Mote *)motpek->mot_node.mln_Succ) {
        if(!MaySeeConf(motpek->nummer, inloggad, &Servermem->inne[nodnr])) continue;
        faci=motpek->namn;
        skri2=skri;
        going2=TRUE;
        if(matchar(skri2,faci)) {
            while(going2) {
                skri2=hittaefter(skri2);
                faci=hittaefter(faci);
                if(skri2[0]==0) return((int)motpek->nummer);
                else if(faci[0]==0) going2=FALSE;
                else if(!matchar(skri2,faci)) {
                    faci=hittaefter(faci);
                    if(faci[0]==0 || !matchar(skri2,faci)) going2=FALSE;
                }
            }
        }
    }
    return(found);
}
Ejemplo n.º 2
0
int endast(void) {
	int antal,foo=TRUE;
	int motnr, nyttmote = 1;
	struct Mote *motpek = NULL;
	if(!isdigit(argument[0])) {
		puttekn("\r\n\nSkriv: Endast <antal texter> [mötesnamn]\r\n",-1);
		return(-5);
	}
	antal=atoi(argument);
	argument=hittaefter(argument);
	if(argument[0])
	{
		if(matchar(argument,Servermem->cfg.brevnamn))
			motnr = -1;
		else
		{
			motnr=parsemot(argument);
			if(motnr==-3)
			{
				puttekn("\r\n\nSkriv: Endast <antal texter> [mötesnamn]\r\n\n",-1);
				return(-5);
			}
			if(motnr==-1)
			{
				puttekn("\r\n\nFinns inget sådant möte!\r\n\n", -1);
				return(-5);
			}
		}
		nyttmote = 0;
	}
	else
		motnr = mote2;

	if(motnr==-1) {
		Servermem->inne[nodnr].brevpek=getnextletter(inloggad)-antal;
		foo=getfirstletter(inloggad);
		if(foo>Servermem->inne[nodnr].brevpek) Servermem->inne[nodnr].brevpek=foo;
	} else {
		motpek = getmotpek(motnr);
		if(motpek->type==MOTE_ORGINAL) org_endast(motnr,antal);
		else if(motpek->type==MOTE_FIDO) fido_endast(motpek,antal);
	}
	if(nyttmote)
		return(-11);
	else
		return(-5);
}
Ejemplo n.º 3
0
int parse(char *str) {
    int argType, timeSinceFirstLogin;
    char *arg2 = NULL, *word2;
    struct Kommando *cmd, *foundCmd = NULL;
    struct LangCommand *langCmd;

    timeSinceFirstLogin = time(NULL) - Servermem->inne[nodnr].forst_in;
    if(str[0] == 0) {
        return -3;
    }
    if(str[0] >= '0' && str[0] <= '9') {
        argument = str;
        return 212;
    }

    arg2 = FindNextWord(str);
    if(IzDigit(arg2[0])) {
        argType = KOMARGNUM;
    } else if(!arg2[0]) {
        argType = KOMARGINGET;
    } else {
        argType = KOMARGCHAR;
    }

    ITER_EL(cmd, Servermem->kom_list, kom_node, struct Kommando *) {
        if(cmd->secret) {
            if(cmd->status > Servermem->inne[nodnr].status) continue;
            if(cmd->minlogg > Servermem->inne[nodnr].loggin) continue;
            if(cmd->mindays * 86400 > timeSinceFirstLogin) continue;
            if(cmd->grupper && !(cmd->grupper & Servermem->inne[nodnr].grupper)) continue;
        }
        langCmd = chooseLangCommand(cmd);
        if(langCmd->name[0] && matchar(str, langCmd->name)) {
            word2 = FindNextWord(langCmd->name);
            if((langCmd->words == 2 && matchar(arg2, word2) && arg2[0]) || langCmd->words == 1) {
                if(langCmd->words == 1) {
                    if(cmd->argument == KOMARGNUM && argType == KOMARGCHAR) continue;
                    if(cmd->argument == KOMARGINGET && argType != KOMARGINGET) continue;
                }
                if(foundCmd == NULL) {
                    foundCmd = cmd;
                }
                else if(foundCmd == (struct Kommando *)1L) {
                    SendString("%s\n\r", chooseLangCommand(cmd)->name);
                } else {
                    SendString("\r\n\n%s\r\n\n", CATSTR(MSG_KOM_AMBIGOUS_COMMAND));
                    SendString("%s\n\r", chooseLangCommand(foundCmd)->name);
                    SendString("%s\n\r", chooseLangCommand(cmd)->name);
                    foundCmd = (struct Kommando *)1L;
                }
            }
        }
    }
    if(foundCmd != NULL && foundCmd != (struct Kommando *)1L) {
        argument = FindNextWord(str);
        if(chooseLangCommand(foundCmd)->words == 2) {
            argument = FindNextWord(argument);
        }
        memset(argbuf, 0, 1080);
        strncpy(argbuf, argument, 1080);
        argbuf[strlen(argument)] = 0;
        argument = argbuf;
    }
    if(foundCmd == NULL) {
        return -1;
    }
    else if(foundCmd == (struct Kommando *)1L) {
        return -2;
    } else {
        if(foundCmd->status > Servermem->inne[nodnr].status || foundCmd->minlogg > Servermem->inne[nodnr].loggin) {
            return -4;
        }
        if(foundCmd->mindays * 86400 > timeSinceFirstLogin) {
            return -4;
        }
        if(foundCmd->grupper && !(foundCmd->grupper & Servermem->inne[nodnr].grupper)) {
            return -4;
        }
    }
    if(foundCmd->losen[0]) {
        SendString("\r\n\n%s: ", CATSTR(MSG_KOM_COMMAND_PASSWORD));
        if(Servermem->inne[nodnr].flaggor & STAREKOFLAG) {
            getstring(STAREKO,20,NULL);
        } else {
            getstring(EJEKO,20,NULL);
        }
        if(strcmp(foundCmd->losen, inmat)) {
            return -5;
        }
    }
    return foundCmd->nummer;
}