void checkpile(int *pile){
    if(pile[0] < 3){
        return;
    } else if(checkvalid(pile[1], pile[2], pile[pile[0]])){
        push_back(pile[1], deck);
        push_back(pile[2], deck);
        push_back(pile[pile[0]], deck);
        pop_front(pile);
        pop_front(pile);
        pop_back(pile);
        checkpile(pile);
    } else if(checkvalid(pile[1], pile[pile[0]-1], pile[pile[0]])){
        push_back(pile[1], deck);
        push_back(pile[pile[0]-1], deck);
        push_back(pile[pile[0]], deck);
        pop_front(pile);
        pop_back(pile);
        pop_back(pile);
        checkpile(pile);
    } else if(checkvalid(pile[pile[0]-2], pile[pile[0]-1], pile[pile[0]])){
        push_back(pile[pile[0]-2], deck);
        push_back(pile[pile[0]-1], deck);
        push_back(pile[pile[0]], deck);
        pop_back(pile);
        pop_back(pile);
        pop_back(pile);
        checkpile(pile);
    } else {
        return;
    }
}
Esempio n. 2
0
File: parse.c Progetto: imr/ngspice
static bool
checkvalid(struct pnode *pn)
{
    while (pn) {
        if (pn->pn_value) {
            if ((pn->pn_value->v_length == 0) &&
                !eq(pn->pn_value->v_name, "list")) {
                if (eq(pn->pn_value->v_name, "all"))
                    fprintf(cp_err,
                            "Error: %s: no matching vectors.\n",
                            pn->pn_value->v_name);
                else
                    fprintf(cp_err,
                            "Error(parse.c--checkvalid): %s: no such vector.\n",
                            pn->pn_value->v_name);
                return (FALSE);
            }
        } else if (pn->pn_func || (pn->pn_op && (pn->pn_op->op_arity == 1))) {
            if (!checkvalid(pn->pn_left))
                return (FALSE);
        } else if (pn->pn_op && (pn->pn_op->op_arity == 2)) {
            if (!checkvalid(pn->pn_left))
                return (FALSE);
            if (!checkvalid(pn->pn_right))
                return (FALSE);
        } else {
            fprintf(cp_err,
                    "checkvalid: Internal Error: bad node\n");
        }
        pn = pn->pn_next;
    }
    return (TRUE);
}
void login::checklogin(){


    QString thisuser=ui->user->text();
    QString thispass=ui->pass->text();

    if(thisuser.count()==0||thispass.count()==0){
        QMessageBox msgBox;
        msgBox.setText("Username or Password cannot be empty");

        msgBox.setStandardButtons(QMessageBox::Close);
        msgBox.setDefaultButton(QMessageBox::Close);
        int ret = msgBox.exec();
    }else if(checkvalid(thisuser,thispass )) {


    temp.setusername(ui->user->text().toStdString());
    temp.setpassword(ui->pass->text().toStdString());
    temp.setip(ui->ip->text().toStdString());
    temp.setport(ui->port->text().toStdString());


    //temp.setsocket(send.connectto(temp.getip(),temp.getport()));


    emit logconnect();

    //send.sendlogin(logger, temp.getsocket());
    //temp.setclient(send);




    }
}
Esempio n. 4
0
File: parse.c Progetto: imr/ngspice
struct pnode *
ft_getpnames(wordlist *wl, bool check)
{
    struct pnode *pn = NULL;
    char *xsbuf, *sbuf;
    int rv;

    if (!wl) {
        fprintf(cp_err, "Warning: NULL arithmetic expression\n");
        return (NULL);
    }

    xsbuf = sbuf = wl_flatten(wl);

    rv = PPparse(&sbuf, &pn);

    tfree(xsbuf);

    if (rv)
        return (NULL);

    if (check && !checkvalid(pn))
        return (NULL);

    return (pn);
}
Esempio n. 5
0
int main(){
    char command[20],first[5],second[5];
    char *temp,*buf;
    int max,from,to;
    void (*func)(int, int, int);
    scanf("%d", &max);
    getchar();
    init_blocks(max);
    while(1){
        fgets(command,20,stdin);
        buf = command;
        if (strcmp(buf,"quit\n") == 0){
            break;
        }
        sscanf(buf,"%s %d %s %d", first, &from, second, &to);
        if(!checkvalid(from,to,max)){
            continue;
        }
        action(first, second, from, to, max);
    }
    output_blocks(max);
    return 0;
}