summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authorPixel <Pixel>2001-04-28 21:40:25 +0000
committerPixel <Pixel>2001-04-28 21:40:25 +0000
commit3b37a00a4be251f87e543d269489cb7a989425d5 (patch)
tree51aedcb4d1627743d6e240266c58a67cf6ae0d67 /hash.c
parentab778d7f896b16f3e6f2b068c2b34d219723002b (diff)
Hop, gros bordel, plein de fichiers ajoutes et supprimes :)
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c188
1 files changed, 0 insertions, 188 deletions
diff --git a/hash.c b/hash.c
deleted file mode 100644
index 9ac65bb..0000000
--- a/hash.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- *
- * Tables de hachage
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "hash.h"
-#include "exceptions.h"
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#else
-#define _(x) x
-#endif
-
-
-static char *CHAINEHACHAGE = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
-
-static int FonctionHachage(char *clef)
-{
- unsigned int i;
-
- if (!clef) {
- exception(1, _("Internal error into hashing"));
- }
-
- for (i = 0; i < strlen(CHAINEHACHAGE); i++) {
- if (clef[0] == CHAINEHACHAGE[i]) {
- return (i);
- }
- }
- return strlen(CHAINEHACHAGE);
-}
-
-_Element CreerElement(char *Nom, _TypeVariable Var)
-{
- _Element e;
-
- e.NomVar = Estrdup(Nom);
-
- e.Variable = Var;
- return (e);
-}
-
-static _ListeChaine InserTete(_ListeChaine l, _Element e)
-{
- _ListeChaine aux;
- unsigned int i;
-
- aux = (_ListeChaine) Emalloc(sizeof(struct _LstChn));
- aux->Elem.NomVar = (char *) Emalloc(sizeof(char) * (strlen(e.NomVar) + 1));
-
- for (i = 0; i <= strlen(e.NomVar); i++) {
- aux->Elem.NomVar[i] = e.NomVar[i];
- }
- aux->Elem.Variable = e.Variable;
- aux->Suivant = l;
- return (aux);
-}
-
-static int EgaliteChaine(char *ch1, char *ch2)
-{
- unsigned int i;
-
- if (strlen(ch1) != strlen(ch2)) {
- return (0);
- }
- for (i = 0; i < strlen(ch1); i++) {
- if (ch1[i] != ch2[i]) {
- return (0);
- }
- }
- return (1);
- /* return (1-strcmp(ch1,ch2)); */
-}
-
-static void Supprimer(_ListeChaine * l, char *Nom)
-{
- _ListeChaine l_aux = NULL;
-
- if ((*l) != NULL) {
- if (EgaliteChaine((*l)->Elem.NomVar, Nom)) {
- l_aux = *l;
- *l = (*l)->Suivant;
- free(l_aux->Elem.NomVar);
- free(l_aux);
- } else {
- Supprimer(&((*l)->Suivant), Nom);
- }
- }
-}
-
-static void Detruit(_ListeChaine * l)
-{
- _ListeChaine l_aux = NULL;
-
- while (*l) {
- l_aux = (*l)->Suivant;
- free((*l)->Elem.NomVar);
- free(*l);
- *l = l_aux;
- }
-}
-
-char SupprimerDansTab(_TableauVariable * t, char *Nom)
-{
- int index = FonctionHachage(Nom);
-
- if (0 <= index && index <= strlen(CHAINEHACHAGE)) {
- Supprimer(&((*t)[index]), Nom);
- } else {
- return (0);
- }
- return (1);
-}
-
-char InsererVarDansTab(_TableauVariable * t, _Element e)
-{
- int index = FonctionHachage(e.NomVar);
-
- if (0 <= index && index <= strlen(CHAINEHACHAGE)) {
- (*t)[index] = InserTete((*t)[index], e);
- } else {
- return (0);
- }
- return (1);
-}
-
-static _TypeVariable NomVarToVarListe(char *Nom, _ListeChaine l, char *trouve)
-{
- *trouve = 0;
- while (l != NULL) {
- if (EgaliteChaine(Nom, (l->Elem).NomVar)) {
- *trouve = 1;
- return (l->Elem.Variable);
- }
- l = l->Suivant;
- }
- return (NULL);
-}
-
-_TypeVariable NomVarToVar(char *Nom, _TableauVariable t, char *trouve)
-{
- return (NomVarToVarListe(Nom, t[FonctionHachage(Nom)], trouve));
-}
-
-void AfficheListe(_ListeChaine l)
-{
- while (l != NULL) {
- fprintf(stderr, "%s\n", l->Elem.NomVar);
- l = l->Suivant;
- }
-}
-
-void AfficheTableau(_TableauVariable t)
-{
- unsigned int i;
-
- for (i = 0; i < TAILLECHAINEHACHAGE; i++) {
- AfficheListe(t[i]);
- }
-}
-
-int Initialise(_TableauVariable * t)
-{
- unsigned int i;
-
-
- (*t) = (_TableauVariable) Emalloc(sizeof(_ListeChaine) * (strlen(CHAINEHACHAGE) + 1));
- for (i = 0; i <= strlen(CHAINEHACHAGE); i++) {
- (*t)[i] = NULL;
- }
- return (i);
-}
-
-void DetruitTab(_TableauVariable * t)
-{
- int i;
-
- for (i = 0; i <= strlen(CHAINEHACHAGE); i++) {
- Detruit(&((*t)[i]));
- }
-
- free(*t);
- *t = NULL;
-}