summaryrefslogtreecommitdiff
path: root/src/htshash.c
diff options
context:
space:
mode:
authorXavier Roche <xroche@users.noreply.github.com>2013-05-14 20:30:28 +0000
committerXavier Roche <xroche@users.noreply.github.com>2013-05-14 20:30:28 +0000
commit07f4b003675260004c49755dde413944a16ca2d3 (patch)
tree11050b4c7fbe1d7c63a38f5f9a6b5ba6d8260ae1 /src/htshash.c
parentb09def438c5e47305e4a5ab18d8a646a3b004fdc (diff)
Indenting cleanup for all *.[ch] files, except htsparse.c (too ugly to be automatically indented for now) and /minizip/, /mmsrip/ (external files)
setup: indent -l80 -lc80 -nhnl -nut -bad -bap -bbo -br -brf -bli2 -brs -bls -br -ss -sai -pmt -nsaw -nsaf -nprs -i2 -ce -npsl -npcs -cs -sob -cdw -nbc -lp logs: indent: ./src/htsback.c:157: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsback.c:1417: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsback.c:1826: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsback.c:1833: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsback.c:1981: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsback.c:2685: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsback.c:2747: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsback.c:2861: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsback.c:3128: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsback.c:3512: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htswizard.c:140: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htswizard.c:597: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htswizard.c:598: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htswizard.c:611: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htscoremain.c:97: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htscoremain.c:106: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htscoremain.c:106: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htscoremain.c:256: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htscoremain.c:262: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htscoremain.c:935: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:271: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:272: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:273: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:274: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:275: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:276: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:277: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:278: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:279: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:280: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:281: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:662: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/httrack.c:752: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:413: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:414: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:415: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:416: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:417: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:418: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:419: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:420: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:421: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:422: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsweb.c:423: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.c:188: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.c:507: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.c:508: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.c:509: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.c:510: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.c:511: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.c:512: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.c:580: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.c:581: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.h:115: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.h:246: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.h:247: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.h:248: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.h:249: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.h:250: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.h:251: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.h:314: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/proxy/proxytrack.h:315: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:151: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:158: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:161: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:166: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:174: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:177: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:188: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:243: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:245: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:248: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:257: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htstools.c:647: Warning:old style assignment ambiguity in "=*". Assuming "= *" indent: ./src/htsbauth.c:364: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htsbauth.c:387: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htscache.c:473: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsserver.h:112: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsserver.h:187: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsjava.c:312: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsjava.c:379: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htsjava.c:407: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsjava.c:472: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htsjava.c:483: Warning:old style assignment ambiguity in "=*". Assuming "= *" indent: ./src/htslib.c:593: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:809: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:1743: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:1874: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:1896: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:1984: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2085: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2604: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2605: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2606: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2607: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2608: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2609: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2672: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2673: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2906: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2928: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:2996: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:4802: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htslib.c:5353: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:5354: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:5355: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:5357: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:5429: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htslib.c:5435: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htscore.c:208: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htscore.c:277: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htscore.c:279: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htscore.c:357: Warning:old style assignment ambiguity in "=*". Assuming "= *" indent: ./src/htscore.c:394: Warning:old style assignment ambiguity in "=*". Assuming "= *" indent: ./src/htscore.c:1544: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htscore.c:3330: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htscore.c:3361: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htshash.c:140: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htshash.c:217: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsname.c:733: Warning:old style assignment ambiguity in "=*". Assuming "= *" indent: ./src/htsname.c:749: Warning:old style assignment ambiguity in "=*". Assuming "= *" indent: ./src/htsname.c:933: Warning:old style assignment ambiguity in "=*". Assuming "= *" indent: ./src/htsname.c:1520: Warning:old style assignment ambiguity in "=*". Assuming "= *" indent: ./src/htszlib.c:76: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htszlib.c:81: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htscatchurl.c:268: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsinthash.c:156: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htsinthash.c:159: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htsinthash.c:176: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htsinthash.c:179: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htsinthash.c:226: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htsinthash.c:253: Warning:old style assignment ambiguity in "=&". Assuming "= &" indent: ./src/htsftp.c:169: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsftp.c:177: Warning:old style assignment ambiguity in "=-". Assuming "= -" indent: ./src/htsfilters.c:67: Warning:old style assignment ambiguity in "=*". Assuming "= *" indent: ./src/htsfilters.c:80: Warning:old style assignment ambiguity in "=*". Assuming "= *"
Diffstat (limited to 'src/htshash.c')
-rw-r--r--src/htshash.c282
1 files changed, 143 insertions, 139 deletions
diff --git a/src/htshash.c b/src/htshash.c
index 034ee81..de673b5 100644
--- a/src/htshash.c
+++ b/src/htshash.c
@@ -17,18 +17,15 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
Important notes:
- We hereby ask people using this source NOT to use it in purpose of grabbing
emails addresses, or collecting any other private information on persons.
This would disgrace our work, and spoil the many hours we spent on it.
-
Please visit our Website: http://www.httrack.com
*/
-
/* ------------------------------------------------------------ */
/* File: httrack.c subroutines: */
/* hash table system (fast index) */
@@ -63,68 +60,70 @@ Please visit our Website: http://www.httrack.com
// type: numero enregistrement - 0 est case insensitive (sav) 1 (adr+fil) 2 (former_adr+former_fil)
// recherche dans la table selon nom1,nom2 et le no d'enregistrement
// retour: position ou -1 si non trouvé
-int hash_read(const hash_struct* hash,const char* nom1,const char* nom2,int type,int normalized) {
- char BIGSTK normfil_[HTS_URLMAXSIZE*2];
- char catbuff[CATBUFF_SIZE];
- const char* normfil;
- const char* normadr;
+int hash_read(const hash_struct * hash, const char *nom1, const char *nom2,
+ int type, int normalized) {
+ char BIGSTK normfil_[HTS_URLMAXSIZE * 2];
+ char catbuff[CATBUFF_SIZE];
+ const char *normfil;
+ const char *normadr;
unsigned int cle;
- int pos;
+ int pos;
+
// calculer la clé de recherche, non modulée
if (type)
- cle = hash_cle(nom1,nom2);
+ cle = hash_cle(nom1, nom2);
else
- cle = hash_cle(convtolower(catbuff,nom1),nom2); // case insensitive
+ cle = hash_cle(convtolower(catbuff, nom1), nom2); // case insensitive
// la position se calcule en modulant
- pos = (int) (cle%HTS_HASH_SIZE);
+ pos = (int) (cle % HTS_HASH_SIZE);
// entrée trouvée?
- if (hash->hash[type][pos] >= 0) { // un ou plusieurs enregistrement(s) avec une telle clé existe..
+ if (hash->hash[type][pos] >= 0) { // un ou plusieurs enregistrement(s) avec une telle clé existe..
// tester table de raccourcis (hash)
// pos est maintenant la position recherchée dans liens
pos = hash->hash[type][pos];
- while (pos>=0) { // parcourir la chaine
+ while(pos >= 0) { // parcourir la chaine
switch (type) {
- case 0: // sav
- if (strfield2(nom1,hash->liens[pos]->sav)) { // case insensitive
+ case 0: // sav
+ if (strfield2(nom1, hash->liens[pos]->sav)) { // case insensitive
#if DEBUG_HASH==2
- printf("hash: found shortcut at %d\n",pos);
+ printf("hash: found shortcut at %d\n", pos);
#endif
return pos;
}
break;
- case 1: // adr+fil
+ case 1: // adr+fil
{
if (!normalized)
- normfil=hash->liens[pos]->fil;
+ normfil = hash->liens[pos]->fil;
else
- normfil=fil_normalized(hash->liens[pos]->fil,normfil_);
+ normfil = fil_normalized(hash->liens[pos]->fil, normfil_);
if (!normalized)
normadr = jump_identification(hash->liens[pos]->adr);
else
normadr = jump_normalized(hash->liens[pos]->adr);
- if ((strfield2(nom1,normadr)!=0) && (strcmp(nom2,normfil)==0)) {
+ if ((strfield2(nom1, normadr) != 0) && (strcmp(nom2, normfil) == 0)) {
#if DEBUG_HASH==2
- printf("hash: found shortcut at %d\n",pos);
+ printf("hash: found shortcut at %d\n", pos);
#endif
return pos;
}
}
break;
- case 2: // former_adr+former_fil
+ case 2: // former_adr+former_fil
{
if (hash->liens[pos]->former_adr) {
if (!normalized)
- normfil=hash->liens[pos]->former_fil;
+ normfil = hash->liens[pos]->former_fil;
else
- normfil=fil_normalized(hash->liens[pos]->former_fil,normfil_);
+ normfil = fil_normalized(hash->liens[pos]->former_fil, normfil_);
if (!normalized)
normadr = jump_identification(hash->liens[pos]->former_adr);
else
normadr = jump_normalized(hash->liens[pos]->former_adr);
-
- if ((strfield2(nom1,normadr)!=0) && (strcmp(nom2,normfil)==0)) {
+
+ if ((strfield2(nom1, normadr) != 0) && (strcmp(nom2, normfil) == 0)) {
#if DEBUG_HASH==2
- printf("hash: found shortcut at %d\n",pos);
+ printf("hash: found shortcut at %d\n", pos);
#endif
return pos;
}
@@ -134,135 +133,140 @@ int hash_read(const hash_struct* hash,const char* nom1,const char* nom2,int type
}
// calculer prochaine position dans la chaine
{
- int old=pos;
- pos=hash->liens[pos]->hash_next[type]; // sinon prochain dans la chaine
- if (old==pos)
- pos=-1; // erreur de bouclage (ne devrait pas arriver)
+ int old = pos;
+
+ pos = hash->liens[pos]->hash_next[type]; // sinon prochain dans la chaine
+ if (old == pos)
+ pos = -1; // erreur de bouclage (ne devrait pas arriver)
}
}
-
+
// Ok va falloir chercher alors..
/*pos=hash->max_lien; // commencer à max_lien
- switch (type) {
- case 0: // sav
- while(pos>=0) {
- if (hash->liens[pos]->hash_sav == cle ) {
- if (strcmp(nom1,hash->liens[pos]->sav)==0) {
- hash->hash[type][(int) (cle%HTS_HASH_SIZE)] = pos; // noter plus récent dans shortcut table
-#if DEBUG_HASH==2
- printf("hash: found long search at %d\n",pos);
-#endif
- return pos;
- }
- }
- pos--;
- }
- break;
- case 1: // adr+fil
- while(pos>=0) {
- if (hash->liens[pos]->hash_adrfil == cle ) {
- if ((strcmp(nom1,hash->liens[pos]->adr)==0) && (strcmp(nom2,hash->liens[pos]->fil)==0)) {
- hash->hash[type][(int) (cle%HTS_HASH_SIZE)] = pos; // noter plus récent dans shortcut table
-#if DEBUG_HASH==2
- printf("hash: found long search at %d\n",pos);
-#endif
- return pos;
- }
- }
- pos--;
- }
- break;
- case 2: // former_adr+former_fil
- while(pos>=0) {
- if (hash->liens[pos]->hash_fadrfil == cle ) {
- if (hash->liens[pos]->former_adr)
- if ((strcmp(nom1,hash->liens[pos]->former_adr)==0) && (strcmp(nom2,hash->liens[pos]->former_fil)==0)) {
- hash->hash[type][(int) (cle%HTS_HASH_SIZE)] = pos; // noter plus récent dans shortcut table
-#if DEBUG_HASH==2
- printf("hash: found long search at %d\n",pos);
-#endif
- return pos;
- }
- }
- pos--;
- }
- }*/
+ switch (type) {
+ case 0: // sav
+ while(pos>=0) {
+ if (hash->liens[pos]->hash_sav == cle ) {
+ if (strcmp(nom1,hash->liens[pos]->sav)==0) {
+ hash->hash[type][(int) (cle%HTS_HASH_SIZE)] = pos; // noter plus récent dans shortcut table
+ #if DEBUG_HASH==2
+ printf("hash: found long search at %d\n",pos);
+ #endif
+ return pos;
+ }
+ }
+ pos--;
+ }
+ break;
+ case 1: // adr+fil
+ while(pos>=0) {
+ if (hash->liens[pos]->hash_adrfil == cle ) {
+ if ((strcmp(nom1,hash->liens[pos]->adr)==0) && (strcmp(nom2,hash->liens[pos]->fil)==0)) {
+ hash->hash[type][(int) (cle%HTS_HASH_SIZE)] = pos; // noter plus récent dans shortcut table
+ #if DEBUG_HASH==2
+ printf("hash: found long search at %d\n",pos);
+ #endif
+ return pos;
+ }
+ }
+ pos--;
+ }
+ break;
+ case 2: // former_adr+former_fil
+ while(pos>=0) {
+ if (hash->liens[pos]->hash_fadrfil == cle ) {
+ if (hash->liens[pos]->former_adr)
+ if ((strcmp(nom1,hash->liens[pos]->former_adr)==0) && (strcmp(nom2,hash->liens[pos]->former_fil)==0)) {
+ hash->hash[type][(int) (cle%HTS_HASH_SIZE)] = pos; // noter plus récent dans shortcut table
+ #if DEBUG_HASH==2
+ printf("hash: found long search at %d\n",pos);
+ #endif
+ return pos;
+ }
+ }
+ pos--;
+ }
+ } */
#if DEBUG_HASH==1
- printf("hash: not found after test %s%s\n",nom1,nom2);
+ printf("hash: not found after test %s%s\n", nom1, nom2);
#endif
- return -1; // non trouvé
+ return -1; // non trouvé
} else {
#if DEBUG_HASH==2
- printf("hash: not found %s%s\n",nom1,nom2);
+ printf("hash: not found %s%s\n", nom1, nom2);
#endif
- return -1; // non trouvé : clé non entrée (même une fois)
+ return -1; // non trouvé : clé non entrée (même une fois)
}
}
// enregistrement lien lpos dans les 3 tables hash1..3
-void hash_write(hash_struct* hash,int lpos,int normalized) {
- char BIGSTK normfil_[HTS_URLMAXSIZE*2];
- char catbuff[CATBUFF_SIZE];
- const char* normfil;
+void hash_write(hash_struct * hash, int lpos, int normalized) {
+ char BIGSTK normfil_[HTS_URLMAXSIZE * 2];
+ char catbuff[CATBUFF_SIZE];
+ const char *normfil;
unsigned int cle;
- int pos;
- int* ptr;
+ int pos;
+ int *ptr;
+
//
- if (hash->liens[lpos]) { // on sait jamais..
- hash->max_lien = max(hash->max_lien,lpos);
+ if (hash->liens[lpos]) { // on sait jamais..
+ hash->max_lien = max(hash->max_lien, lpos);
#if DEBUG_HASH
- hashnumber=hash->max_lien;
+ hashnumber = hash->max_lien;
#endif
// élément actuel sur -1 (fin de chaine)
- hash->liens[lpos]->hash_next[0]=hash->liens[lpos]->hash_next[1]=hash->liens[lpos]->hash_next[2]=-1;
+ hash->liens[lpos]->hash_next[0] = hash->liens[lpos]->hash_next[1] =
+ hash->liens[lpos]->hash_next[2] = -1;
//
- cle = hash_cle(convtolower(catbuff,hash->liens[lpos]->sav),""); // CASE INSENSITIVE
- pos = (int) (cle%HTS_HASH_SIZE);
- ptr = hash_calc_chaine(hash,0,pos); // calculer adresse chaine
- *ptr = lpos; // noter dernier enregistré
+ cle = hash_cle(convtolower(catbuff, hash->liens[lpos]->sav), ""); // CASE INSENSITIVE
+ pos = (int) (cle % HTS_HASH_SIZE);
+ ptr = hash_calc_chaine(hash, 0, pos); // calculer adresse chaine
+ *ptr = lpos; // noter dernier enregistré
#if DEBUG_HASH==3
- printf("[%d",pos);
+ printf("[%d", pos);
#endif
//
if (!normalized)
- normfil=hash->liens[lpos]->fil;
+ normfil = hash->liens[lpos]->fil;
else
- normfil=fil_normalized(hash->liens[lpos]->fil,normfil_);
+ normfil = fil_normalized(hash->liens[lpos]->fil, normfil_);
if (!normalized)
- cle = hash_cle(jump_identification(hash->liens[lpos]->adr),normfil);
+ cle = hash_cle(jump_identification(hash->liens[lpos]->adr), normfil);
else
- cle = hash_cle(jump_normalized(hash->liens[lpos]->adr),normfil);
- pos = (int) (cle%HTS_HASH_SIZE);
- ptr = hash_calc_chaine(hash,1,pos); // calculer adresse chaine
- *ptr = lpos; // noter dernier enregistré
+ cle = hash_cle(jump_normalized(hash->liens[lpos]->adr), normfil);
+ pos = (int) (cle % HTS_HASH_SIZE);
+ ptr = hash_calc_chaine(hash, 1, pos); // calculer adresse chaine
+ *ptr = lpos; // noter dernier enregistré
#if DEBUG_HASH==3
- printf(",%d",pos);
+ printf(",%d", pos);
#endif
//
- if (hash->liens[lpos]->former_adr) { // former_adr existe?
+ if (hash->liens[lpos]->former_adr) { // former_adr existe?
if (!normalized)
- normfil=hash->liens[lpos]->former_fil;
+ normfil = hash->liens[lpos]->former_fil;
else
- normfil=fil_normalized(hash->liens[lpos]->former_fil,normfil_);
+ normfil = fil_normalized(hash->liens[lpos]->former_fil, normfil_);
if (!normalized)
- cle = hash_cle(jump_identification(hash->liens[lpos]->former_adr),normfil);
+ cle =
+ hash_cle(jump_identification(hash->liens[lpos]->former_adr), normfil);
else
- cle = hash_cle(jump_normalized(hash->liens[lpos]->former_adr),normfil);
- pos = (int) (cle%HTS_HASH_SIZE);
- ptr = hash_calc_chaine(hash,2,pos); // calculer adresse chaine
- *ptr = lpos; // noter dernier enregistré
+ cle = hash_cle(jump_normalized(hash->liens[lpos]->former_adr), normfil);
+ pos = (int) (cle % HTS_HASH_SIZE);
+ ptr = hash_calc_chaine(hash, 2, pos); // calculer adresse chaine
+ *ptr = lpos; // noter dernier enregistré
#if DEBUG_HASH==3
- printf(",%d",pos);
+ printf(",%d", pos);
#endif
}
#if DEBUG_HASH==3
- printf("] "); fflush(stdout);
+ printf("] ");
+ fflush(stdout);
#endif
}
#if DEBUT_HASH
else {
printf("* hash_write=0!!\n");
- abortLogFmt("unexpected error in hash_write (pos=%d)" _ pos);
+ abortLogFmt("unexpected error in hash_write (pos=%d)" _pos);
abort();
}
#endif
@@ -271,37 +275,37 @@ void hash_write(hash_struct* hash,int lpos,int normalized) {
// calcul clé
// il n'y a pas de formule de hashage universelle, celle-ci semble acceptable..
-unsigned long int hash_cle(const char* nom1, const char* nom2) {
+unsigned long int hash_cle(const char *nom1, const char *nom2) {
/*
- unsigned int sum=0;
- int i=0;
- while(*nom1) {
- sum += 1;
- sum += (unsigned int) *(nom1);
- sum *= (unsigned int) *(nom1++);
- sum += (unsigned int) i;
- i++;
- }
- while(*nom2) {
- sum += 1;
- sum += (unsigned int) *(nom2);
- sum *= (unsigned int) *(nom2++);
- sum += (unsigned int) i;
- i++;
- }
- */
+ unsigned int sum=0;
+ int i=0;
+ while(*nom1) {
+ sum += 1;
+ sum += (unsigned int) *(nom1);
+ sum *= (unsigned int) *(nom1++);
+ sum += (unsigned int) i;
+ i++;
+ }
+ while(*nom2) {
+ sum += 1;
+ sum += (unsigned int) *(nom2);
+ sum *= (unsigned int) *(nom2++);
+ sum += (unsigned int) i;
+ i++;
+ }
+ */
return md5sum32(nom1)
- +md5sum32(nom2);
+ + md5sum32(nom2);
}
// calcul de la position finale dans la chaine des elements ayant la même clé
-int* hash_calc_chaine(hash_struct* hash,int type,int pos) {
+int *hash_calc_chaine(hash_struct * hash, int type, int pos) {
#if DEBUG_HASH
- int count=0;
+ int count = 0;
#endif
if (hash->hash[type][pos] == -1)
return &(hash->hash[type][pos]); // premier élément dans la chaine
- pos=hash->hash[type][pos];
+ pos = hash->hash[type][pos];
while(hash->liens[pos]->hash_next[type] != -1) {
pos = hash->liens[pos]->hash_next[type];
#if DEBUG_HASH
@@ -310,9 +314,9 @@ int* hash_calc_chaine(hash_struct* hash,int type,int pos) {
}
#if DEBUG_HASH
count++;
- longest_hash[type]=max(longest_hash[type],count);
+ longest_hash[type] = max(longest_hash[type], count);
#endif
return &(hash->liens[pos]->hash_next[type]);
}
-// FIN GESTION DES TABLES DE HACHAGE
+// FIN GESTION DES TABLES DE HACHAGE