ReactOS 0.4.16-dev-125-g798ea90
hash.c File Reference
#include <stdio.h>
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "widltypes.h"
#include "hash.h"
Include dependency graph for hash.c:

Go to the source code of this file.

Functions

unsigned int lhash_val_of_name_sys (syskind_t skind, LCID lcid, LPCSTR lpStr)
 

Variables

static const unsigned char Lookup_16 [128 *3]
 
static const unsigned char Lookup_32 [128 *3]
 
static const unsigned char Lookup_48 [128 *3]
 
static const unsigned char Lookup_64 [128 *3]
 
static const unsigned char Lookup_80 [128 *3]
 
static const unsigned char Lookup_112 [128 *3]
 
static const unsigned char Lookup_128 [128 *3]
 
static const unsigned char Lookup_144 [128 *3]
 
static const unsigned char Lookup_160 [128 *3]
 
static const unsigned char Lookup_176 [128 *3]
 
static const unsigned char Lookup_208 [128 *3]
 
static const unsigned char Lookup_224 [128 *3]
 

Function Documentation

◆ lhash_val_of_name_sys()

unsigned int lhash_val_of_name_sys ( syskind_t  skind,
LCID  lcid,
LPCSTR  lpStr 
)

Definition at line 510 of file hash.c.

511{
512 ULONG nOffset, nMask = skind == SYS_MAC ? 1 : 0;
513 ULONG nHiWord, nLoWord = 0x0deadbee;
514 const unsigned char *str = (const unsigned char *)lpStr, *pnLookup = NULL;
515
516 if (!str)
517 return 0;
518
519 switch (PRIMARYLANGID(LANGIDFROMLCID(lcid)))
520 {
521 default:
522 fprintf(stderr, "Unknown lcid %x, treating as latin-based, please report\n", lcid);
523 /* .. Fall Through .. */
525 case LANG_ASSAMESE: case LANG_AZERI: case LANG_BASQUE:
527 case LANG_CATALAN: case LANG_DANISH: case LANG_DIVEHI:
528 case LANG_DUTCH: case LANG_ENGLISH: case LANG_ESTONIAN:
529 case LANG_FAEROESE: case LANG_FINNISH: case LANG_FRENCH:
530 case LANG_GALICIAN: case LANG_GEORGIAN: case LANG_GERMAN:
532 case LANG_ITALIAN: case LANG_KANNADA: case LANG_KASHMIRI:
533 case LANG_KAZAK: case LANG_KONKANI: case LANG_KYRGYZ:
535 case LANG_MALAY: case LANG_MALAYALAM: case LANG_MANIPURI:
536 case LANG_MARATHI: case LANG_MONGOLIAN: case LANG_NEPALI:
537 case LANG_ORIYA: case LANG_PORTUGUESE: case LANG_PUNJABI:
539 case LANG_SINDHI: case LANG_SLOVENIAN: case LANG_SWAHILI:
540 case LANG_SWEDISH: case LANG_SYRIAC: case LANG_TAMIL:
541 case LANG_TATAR: case LANG_TELUGU: case LANG_THAI:
542 case LANG_UKRAINIAN: case LANG_URDU: case LANG_UZBEK:
543 case LANG_VIETNAMESE: case LANG_MALTESE: case LANG_IRISH:
545 case LANG_XHOSA: case LANG_ZULU: case LANG_WELSH:
546 case LANG_BRETON: case LANG_NEUTRAL:
547/* some languages not in all windows versions or ReactOS */
548#ifdef LANG_GAELIC
549 case LANG_GAELIC:
550#endif
551#ifdef LANG_TAJIK
552 case LANG_TAJIK:
553#endif
554#ifdef LANG_ROMANSH
555 case LANG_ROMANSH:
556#endif
557#ifdef LANG_SUTU
558 case LANG_SUTU:
559#endif
560#ifdef LANG_TSONGA
561 case LANG_TSONGA:
562#endif
563#ifdef LANG_VENDA
564 case LANG_VENDA:
565#endif
566#ifdef LANG_ESPERANTO
567 case LANG_ESPERANTO:
568#endif
569#ifdef LANG_WALON
570 case LANG_WALON:
571#endif
572#ifdef LANG_CORNISH
573 case LANG_CORNISH:
574#endif
575 nOffset = 16;
576 pnLookup = Lookup_16;
577 break;
578 case LANG_CZECH: case LANG_HUNGARIAN: case LANG_POLISH:
579 case LANG_SLOVAK: case LANG_SPANISH:
580 nOffset = 32;
581 pnLookup = Lookup_32;
582 break;
583 case LANG_HEBREW:
584 nOffset = 48;
585 pnLookup = Lookup_48;
586 break;
587 case LANG_JAPANESE:
588 nOffset = 64;
589 pnLookup = Lookup_64;
590 break;
591 case LANG_KOREAN:
592 nOffset = 80;
593 pnLookup = Lookup_80;
594 break;
595 case LANG_CHINESE:
596 nOffset = 112;
597 pnLookup = Lookup_112;
598 break;
599 case LANG_GREEK:
600 nOffset = 128;
601 pnLookup = Lookup_128;
602 break;
603 case LANG_ICELANDIC:
604 nOffset = 144;
605 pnLookup = Lookup_144;
606 break;
607 case LANG_TURKISH:
608 nOffset = 160;
609 pnLookup = Lookup_160;
610 break;
611 case LANG_NORWEGIAN:
613 {
614 nOffset = 176;
615 pnLookup = Lookup_176;
616 }
617 else
618 {
619 nOffset = 16;
620 pnLookup = Lookup_16;
621 }
622 break;
623 case LANG_ARABIC:
624 case LANG_FARSI:
625 nOffset = 208;
626 pnLookup = Lookup_208;
627 break;
628 case LANG_RUSSIAN:
629 nOffset = 224;
630 pnLookup = Lookup_224;
631 break;
632 }
633
634 nHiWord = (nOffset | nMask) << 16;
635
636 while (*str)
637 {
638 nLoWord = 37 * nLoWord + pnLookup[*str > 0x7f && nMask ? *str + 0x80 : *str];
639 str++;
640 }
641 /* Constrain to a prime modulo and sizeof(WORD) */
642 nLoWord = (nLoWord % 65599) & 0xffff;
643
644 return nHiWord | nLoWord;
645}
#define NULL
Definition: types.h:112
static const unsigned char Lookup_16[128 *3]
Definition: hash.c:32
static const unsigned char Lookup_208[128 *3]
Definition: hash.c:411
static const unsigned char Lookup_112[128 *3]
Definition: hash.c:221
static const unsigned char Lookup_48[128 *3]
Definition: hash.c:108
static const unsigned char Lookup_128[128 *3]
Definition: hash.c:259
static const unsigned char Lookup_144[128 *3]
Definition: hash.c:297
static const unsigned char Lookup_80[128 *3]
Definition: hash.c:183
static const unsigned char Lookup_224[128 *3]
Definition: hash.c:449
static const unsigned char Lookup_160[128 *3]
Definition: hash.c:335
static const unsigned char Lookup_32[128 *3]
Definition: hash.c:70
static const unsigned char Lookup_64[128 *3]
Definition: hash.c:146
static const unsigned char Lookup_176[128 *3]
Definition: hash.c:373
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
const WCHAR * str
#define LANG_TATAR
Definition: nls.h:130
#define LANG_MALAYALAM
Definition: nls.h:93
#define LANG_KONKANI
Definition: nls.h:83
#define SUBLANG_NORWEGIAN_NYNORSK
Definition: nls.h:301
#define LANG_HINDI
Definition: nls.h:68
#define LANG_VENDA
Definition: nls.h:158
#define LANG_TAMIL
Definition: nls.h:129
#define LANG_MALTESE
Definition: nls.h:94
#define LANG_FARSI
Definition: nls.h:55
#define LANG_NEUTRAL
Definition: nls.h:22
#define LANG_THAI
Definition: nls.h:132
#define LANG_LITHUANIAN
Definition: nls.h:88
#define LANG_ASSAMESE
Definition: nls.h:31
#define LANG_NORWEGIAN
Definition: nls.h:102
#define LANG_TSONGA
Definition: nls.h:157
#define SUBLANGID(l)
Definition: nls.h:17
#define LANG_ALBANIAN
Definition: nls.h:26
#define LANG_TURKISH
Definition: nls.h:136
#define LANG_SANSKRIT
Definition: nls.h:115
#define LANG_KASHMIRI
Definition: nls.h:78
#define LANG_DANISH
Definition: nls.h:48
#define LANG_SPANISH
Definition: nls.h:123
#define LANG_POLISH
Definition: nls.h:107
#define LANG_AZERI
Definition: nls.h:32
#define LANG_NEPALI
Definition: nls.h:101
#define LANG_SYRIAC
Definition: nls.h:126
#define LANG_GALICIAN
Definition: nls.h:60
#define LANG_INDONESIAN
Definition: nls.h:72
#define LANG_GERMAN
Definition: nls.h:62
#define LANG_ESTONIAN
Definition: nls.h:53
#define LANG_WALON
Definition: nls.h:162
#define LANG_HEBREW
Definition: nls.h:67
#define LANG_KANNADA
Definition: nls.h:77
#define LANG_ORIYA
Definition: nls.h:104
#define LANG_UKRAINIAN
Definition: nls.h:139
#define LANG_GAELIC
Definition: nls.h:164
#define LANG_SUTU
Definition: nls.h:156
#define LANG_URDU
Definition: nls.h:141
#define LANG_BULGARIAN
Definition: nls.h:40
#define LANG_FINNISH
Definition: nls.h:57
#define LANG_XHOSA
Definition: nls.h:146
#define LANG_BELARUSIAN
Definition: nls.h:35
#define LANG_ROMANSH
Definition: nls.h:112
#define LANG_GEORGIAN
Definition: nls.h:61
#define LANG_GREEK
Definition: nls.h:63
#define LANG_TSWANA
Definition: nls.h:135
#define LANG_BASQUE
Definition: nls.h:34
#define LANG_MACEDONIAN
Definition: nls.h:91
#define LANG_ENGLISH
Definition: nls.h:52
#define LANGIDFROMLCID(l)
Definition: nls.h:18
#define LANG_ROMANIAN
Definition: nls.h:111
#define LANG_ZULU
Definition: nls.h:150
#define LANG_MALAY
Definition: nls.h:92
#define LANG_BENGALI
Definition: nls.h:36
#define LANG_DUTCH
Definition: nls.h:51
#define LANG_MANIPURI
Definition: nls.h:95
#define LANG_ESPERANTO
Definition: nls.h:161
#define LANG_RUSSIAN
Definition: nls.h:113
#define LANG_VIETNAMESE
Definition: nls.h:143
#define LANG_PUNJABI
Definition: nls.h:109
#define LANG_CZECH
Definition: nls.h:47
#define LANG_HUNGARIAN
Definition: nls.h:69
#define LANG_SWEDISH
Definition: nls.h:125
#define LANG_ARABIC
Definition: nls.h:29
#define LANG_UPPER_SORBIAN
Definition: nls.h:140
#define LANG_KYRGYZ
Definition: nls.h:85
#define LANG_CHINESE
Definition: nls.h:42
#define LANG_SERBIAN
Definition: nls.h:116
#define LANG_JAPANESE
Definition: nls.h:76
#define LANG_SAMI
Definition: nls.h:114
#define PRIMARYLANGID(l)
Definition: nls.h:16
#define LANG_DIVEHI
Definition: nls.h:50
#define LANG_LATVIAN
Definition: nls.h:87
#define LANG_BRETON
Definition: nls.h:39
#define LANG_ICELANDIC
Definition: nls.h:70
#define LANG_SINDHI
Definition: nls.h:118
#define LANG_SLOVAK
Definition: nls.h:120
#define LANG_KOREAN
Definition: nls.h:84
#define LANG_AFRIKAANS
Definition: nls.h:25
#define LANG_SLOVENIAN
Definition: nls.h:121
#define LANG_CORNISH
Definition: nls.h:163
#define LANG_TAJIK
Definition: nls.h:127
#define LANG_GUJARATI
Definition: nls.h:65
#define LANG_WELSH
Definition: nls.h:144
#define LANG_MARATHI
Definition: nls.h:98
#define LANG_SWAHILI
Definition: nls.h:124
#define LANG_FRENCH
Definition: nls.h:58
#define LANG_UZBEK
Definition: nls.h:142
#define LANG_TELUGU
Definition: nls.h:131
#define LANG_ITALIAN
Definition: nls.h:75
#define LANG_ARMENIAN
Definition: nls.h:30
#define LANG_PORTUGUESE
Definition: nls.h:108
#define LANG_CATALAN
Definition: nls.h:41
#define LANG_KAZAK
Definition: nls.h:79
#define LANG_MONGOLIAN
Definition: nls.h:100
#define LANG_IRISH
Definition: nls.h:74
#define LANG_FAEROESE
Definition: nls.h:54
uint32_t ULONG
Definition: typedefs.h:59
@ SYS_MAC
Definition: widltypes.h:553

Referenced by ctl2_encode_name().

Variable Documentation

◆ Lookup_112

const unsigned char Lookup_112[128 *3]
static

Definition at line 224 of file hash.c.

◆ Lookup_128

const unsigned char Lookup_128[128 *3]
static

Definition at line 262 of file hash.c.

◆ Lookup_144

const unsigned char Lookup_144[128 *3]
static

Definition at line 300 of file hash.c.

◆ Lookup_16

const unsigned char Lookup_16[128 *3]
static

Definition at line 35 of file hash.c.

◆ Lookup_160

const unsigned char Lookup_160[128 *3]
static

Definition at line 338 of file hash.c.

◆ Lookup_176

const unsigned char Lookup_176[128 *3]
static

Definition at line 376 of file hash.c.

◆ Lookup_208

const unsigned char Lookup_208[128 *3]
static

Definition at line 414 of file hash.c.

◆ Lookup_224

const unsigned char Lookup_224[128 *3]
static

Definition at line 452 of file hash.c.

◆ Lookup_32

const unsigned char Lookup_32[128 *3]
static

Definition at line 73 of file hash.c.

◆ Lookup_48

const unsigned char Lookup_48[128 *3]
static

Definition at line 111 of file hash.c.

◆ Lookup_64

const unsigned char Lookup_64[128 *3]
static

Definition at line 149 of file hash.c.

◆ Lookup_80

const unsigned char Lookup_80[128 *3]
static

Definition at line 186 of file hash.c.