Пример #1
0
void io_register(struct dict *funcs) {
    struct func *f;

    f = calloc(1, sizeof(struct func));
    f->name = "open";
    f->type = F_SPEC;
    f->spec = fiopen;
    dictadd(funcs, f, f->name);
    
    f = calloc(1, sizeof(struct func));
    f->name = "write";
    f->type = F_SPEC;
    f->spec = output;
    dictadd(funcs, f, f->name);
    
    f = calloc(1, sizeof(struct func));
    f->name = "input";
    f->type = F_SPEC;
    f->spec = input;
    dictadd(funcs, f, f->name);

    f = calloc(1, sizeof(struct func));
    f->name = "read";
    f->type = F_SPEC;
    f->spec = inread;
    dictadd(funcs, f, f->name);
}
Пример #2
0
int main() {
    dict_t valeur = dictcreate();
    dict_t* dico = &valeur;
    dictdump(dico);
    dico = dictadd(dico, "Lamantin", "Sympathique animal marin");
    dico = dictadd(dico, "Loutre", "Rongeur de rivieres");
    dico = dictadd(dico, "Pelican", "Oiseau au grand bec");
    dico = dictadd(dico, "Stupide", "Definition inutile!!!!!");
    dico = dictadd(dico, "Crocodile", "Dangereux saurien");
    dico = dictup(dico, "Loutre", "Rongeur de rivieres au pelage soyeux");
    dico = dictrm(dico, "Stupide");
    dictdump(dico);
    char buf[200];
    dictget(dico, "Loutre", buf);
    printf("La definition de Loutre est %s\n",  buf);
    printf("Le dictionnaire fait presentement %d taille %d maxtaille\n", (*dico).size, (*dico).maxsize);
    dictdestroy(dico);
}
Пример #3
0
void arith_register(struct dict *funcs) {
    struct func *f;
    
    f = calloc(1, sizeof(struct func));
    f->name = "+";
    f->type = F_SPEC;
    f->spec = add;
    dictadd(funcs, f, f->name);
    
    f = calloc(1, sizeof(struct func));
    f->name = "/";
    f->type = F_SPEC;
    f->spec = divd;
    dictadd(funcs, f, f->name);
    
    f = calloc(1, sizeof(struct func));
    f->name = "*";
    f->type = F_SPEC;
    f->spec = mult;
    dictadd(funcs, f, f->name);
    
    f = calloc(1, sizeof(struct func));
    f->name = "-";
    f->type = F_SPEC;
    f->spec = minus;
    dictadd(funcs, f, f->name);
    
    f = calloc(1, sizeof(struct func));
    f->name = "%";
    f->type = F_SPEC;
    f->spec = mod;
    dictadd(funcs, f, f->name);
    
    f = calloc(1, sizeof(struct func));
    f->name = "random";
    f->type = F_SPEC;
    f->spec = ran;
    dictadd(funcs, f, f->name);
    
    f = calloc(1, sizeof(struct func));
    f->name = "^";
    f->type = F_SPEC;
    f->spec = power;
    dictadd(funcs, f, f->name);
}