#ifndef LISTS_C #define LISTS_C #include /* #include */ #include #include #include "lists.h" #define NEW(type) (calloc(1,sizeof(type))) /* Inserer un chaine de caracteres en tete de liste */ List list_add(const char *str, List old) { List new=NEW(struct lnode); new->content=strdup(str); if(old == NULL) return new; new->next=old; return new; } int list_length(List l) { int i; for(i = 0; l!= NULL; l=l->next,i++) ; return i; } int list_index(const char * str, List l) { List start=l; int i; for(i = 0; l!= NULL; l=l->next,i++) { if(strcmp(l->content,str)==0) return list_length(start) - i; } return 0; } #endif /* LISTS_C */