Last active
July 19, 2022 19:43
-
-
Save skeeto/39d4f5a3d9cc580025ed8d25b5d5c590 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import pprint | |
d = {} | |
seen = set() | |
keys = [] | |
icon = None | |
for line in sys.stdin: | |
off = line.find(' icon =') | |
if off >= 0: | |
icon = ord(line[off+9]) | |
#icon = f"U+{icon:04x}" | |
d[icon] = keys | |
keys = [] | |
#print(f"U+{icon:x}") | |
continue | |
while True: | |
off = line.find("strcmp") | |
if off == -1: | |
break | |
line = line[off+12:] | |
end = line.find('"') | |
key = line[:end] | |
keys.append(key) | |
if key in seen: | |
pass | |
#print(key) | |
else: | |
seen.add(key) | |
#print("\t",key) | |
line = line[end:] | |
ext = {} | |
for k in d: | |
for v in d[k]: | |
ext[v] = k | |
for k in sorted(ext): | |
print(f'"{k}" = 0x{ext[k]:04x},') | |
#ext = list(sorted(seen)) | |
#pprint.pprint(ext) | |
#pprint.pprint(d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static char * | |
get_icon(Pane *pane, size_t entpos, Cpair col, mode_t mode){ | |
char *ex, *icon; | |
char *full_str; | |
full_str = basename(pane->direntr[entpos].name); | |
ex = get_ext(full_str); | |
switch (mode & S_IFMT) { | |
case S_IFDIR: /* folders */ | |
if(strcmp(ex, "own") == 0) /* downloads */ | |
icon = " "; | |
else if(strcmp(ex, "oc") == 0) /* documents */ | |
icon = " "; | |
else if(strcmp(ex, "us") == 0) /* music */ | |
icon = "ﱘ "; | |
else if(strcmp(ex, "ic") == 0) /* pictures */ | |
icon = " "; | |
else if(strcmp(ex, "id") == 0) /* videos */ | |
icon = " "; | |
else if(strcmp(ex, "ext") == 0) /* nextcloud */ | |
icon = " "; | |
else if(strcmp(ex, "stea") == 0) /* steam */ | |
icon = " "; | |
else | |
/* Uncomment to get the folders "extensions" | |
* then change above (comment again after) */ | |
//icon = ex; /* debug */ | |
icon = " "; /* default folder */ | |
break; | |
case S_IFLNK: /* links */ | |
icon = " "; | |
break; | |
case S_IFREG: | |
case S_IFBLK: | |
case S_IFCHR: | |
case S_IFIFO: | |
case S_IFSOCK: /* files */ | |
if(strcmp(ex, "c") == 0) | |
icon = " "; | |
else if(strcmp(ex, "h") == 0) | |
icon = " "; | |
else if(strcmp(ex, "mk") == 0 || strcmp(ex, "akef") == 0) | |
icon = " "; | |
else if(strcmp(ex, "o") == 0 || strcmp(ex, "a") == 0 || strcmp(ex, "so") == 0) | |
icon = " "; | |
else if(strcmp(ex, "git") == 0 || strcmp(ex, "giti") == 0) | |
icon = " "; | |
else if(strcmp(ex, "diff") == 0 || strcmp(ex, "patch") == 0 || strcmp(ex, "atch") == 0) | |
icon = " "; | |
else if(strcmp(ex, "c++") == 0) | |
icon = "ﭱ "; | |
else if(strcmp(ex, "cs") == 0) | |
icon = " "; | |
else if(strcmp(ex, "html") == 0) | |
icon = " "; | |
else if(strcmp(ex, "css") == 0) | |
icon = " "; | |
else if(strcmp(ex, "md") == 0) | |
icon = " "; | |
else if(strcmp(ex, "bib") == 0) | |
icon = " "; | |
else if(strcmp(ex, "sh") == 0 || strcmp(ex, "ksh") == 0) | |
icon = " "; | |
else if(strcmp(ex, "Rmd") == 0 || strcmp(ex, "r") == 0 || strcmp(ex, "R") == 0 || strcmp(ex, "rmd") == 0 || strcmp(ex, "m") == 0) | |
icon = "ﳒ "; | |
else if(strcmp(ex, "go") == 0) | |
icon = "ﳑ "; | |
else if(strcmp(ex, "jar") == 0 || strcmp(ex, "java") == 0) | |
icon = " "; | |
else if(strcmp(ex, "js") == 0) | |
icon = " "; | |
else if(strcmp(ex, "php") == 0) | |
icon = " "; | |
else if(strcmp(ex, "py") == 0) | |
icon = " "; | |
else if(strcmp(ex, "swift") == 0) | |
icon = "ﯣ "; | |
else if(strcmp(ex, "ts") == 0) | |
icon = "ﯤ "; | |
else if(strcmp(ex, "1") == 0 || strcmp(ex, "man") == 0) | |
icon = " "; | |
else if(strcmp(ex, "pdf") == 0 || strcmp(ex, "djvu") == 0 || strcmp(ex, "epub") == 0){ | |
icon = " "; | |
} | |
else if(strcmp(ex, "zip") == 0 || strcmp(ex, "rar") == 0 || strcmp(ex, "tar") == 0 || strcmp(ex, "gz") == 0 || strcmp(ex, "7z") == 0 || strcmp(ex, "gzip") == 0) | |
icon = " "; | |
else if(strcmp(ex, "txt") == 0 || strcmp(ex, "me") == 0 || strcmp(ex, "ms") == 0 || strcmp(ex, "org") == 0 || strcmp(ex, "doc") == 0 || strcmp(ex, "docx") == 0 || strcmp(ex, "odt") == 0 || strcmp(ex, "gdoc") == 0 || strcmp(ex, "gdocx") == 0 || strcmp(ex, "tex") == 0) | |
icon = " "; | |
else if(strcmp(ex, "xls") == 0 || strcmp(ex, "xlsx") == 0 || strcmp(ex, "ods") == 0 || strcmp(ex, "csv") == 0) | |
icon = " "; | |
else if(strcmp(ex, "odp") == 0 || strcmp(ex, "pptx") == 0) | |
icon = " "; | |
else if(strcmp(ex, "mp3") == 0 || strcmp(ex, "wav") == 0 || strcmp(ex, "flac") == 0 || strcmp(ex, "m4a") == 0 || strcmp(ex, "opus") == 0 || strcmp(ex, "ogg") == 0) | |
icon = " "; | |
else if(strcmp(ex, "png") == 0 || strcmp(ex, "webp") == 0 || strcmp(ex, "ico") == 0 || strcmp(ex, "jpg") == 0 || strcmp(ex, "jpe") == 0 || strcmp(ex, "jpeg") == 0 || strcmp(ex, "gif") == 0 || strcmp(ex, "art") == 0 || strcmp(ex, "tif") == 0 || strcmp(ex, "tiff") == 0 || strcmp(ex, "xpm") == 0 || strcmp(ex, "icon") == 0 || strcmp(ex, "xcf") == 0 || strcmp(ex, "psd") == 0 || strcmp(ex, "bmp") == 0) | |
icon = " "; | |
else if(strcmp(ex, "svg") == 0 || strcmp(ex, "ps") == 0 || strcmp(ex, "ai") == 0 || strcmp(ex, "cdr") == 0 || strcmp(ex, "inx") == 0 || strcmp(ex, "odg") == 0) | |
icon = "縉"; | |
else if(strcmp(ex, "mp4") == 0 || strcmp(ex, "kden") == 0 || strcmp(ex, "mov") == 0 || strcmp(ex, "mkv") == 0 || strcmp(ex, "webm") == 0 || strcmp(ex, "mpeg") == 0 || strcmp(ex, "avi") == 0 || strcmp(ex, "wmv") == 0 || strcmp(ex, "mpg") == 0 || strcmp(ex, "flv") == 0 || strcmp(ex, "m4b") == 0) | |
icon = " "; | |
else if(strcmp(ex, "xml") == 0) | |
icon = "爵"; | |
else if(strcmp(ex, "gpg") == 0 || strcmp(ex, "pgp") == 0 || strcmp(ex, "icen") == 0) | |
icon = " "; | |
else if(strcmp(ex, "vim") == 0 || strcmp(ex, "nvim") == 0) | |
icon = " "; | |
else if(strcmp(ex, "nfo") == 0 || strcmp(ex, "info") == 0) | |
icon = " "; | |
else if(strcmp(ex, "torrent") == 0 || strcmp(ex, "part") == 0) | |
icon = "ﯲ "; | |
else if(strcmp(ex, "iso") == 0 || strcmp(ex, "img") == 0 || strcmp(ex, "rom") == 0 || strcmp(ex, "dmg") == 0) | |
icon = " "; | |
else if(strcmp(ex, "log") == 0) | |
icon = "ﴬ "; | |
else if(strcmp(ex, "z64") == 0 || strcmp(ex, "v64") == 0 || strcmp(ex, "n64") == 0 || strcmp(ex, "jap") == 0 || strcmp(ex, "gba") == 0 || strcmp(ex, "gb") == 0 || strcmp(ex, "gbc") == 0 || strcmp(ex, "agb") == 0 || strcmp(ex, "nes") == 0 || strcmp(ex, "sms") == 0 || strcmp(ex, "smc") == 0 || strcmp(ex, "sfc") == 0 || strcmp(ex, "fds") == 0 || strcmp(ex, "nds") == 0 || strcmp(ex, "vb") == 0 || strcmp(ex, "gcm") == 0 || strcmp(ex, "3ds") == 0 || strcmp(ex, "gdi") == 0 || strcmp(ex, "rvz") == 0 || strcmp(ex, "srl") == 0 || strcmp(ex, "sms") == 0 || strcmp(ex, "sgb") == 0 || strcmp(ex, "gcz") == 0 || strcmp(ex, "3dz") == 0 || strcmp(ex, "gen") == 0 || strcmp(ex, "smd") == 0 || strcmp(ex, "gg") == 0 || strcmp(ex, "32x") == 0 || strcmp(ex, "st") == 0 || strcmp(ex, "atr") == 0 || strcmp(ex, "mii") == 0 || strcmp(ex, "pss") == 0 || strcmp(ex, "ngp") == 0 || strcmp(ex, "ngc") == 0 || strcmp(ex, "elf") == 0 || strcmp(ex, "wud") == 0 || strcmp(ex, "nro") == 0) | |
icon = " "; | |
else | |
//icon = ex; /* debug */ | |
icon = ""; | |
break; | |
default: | |
//icon = ex; /* debug */ | |
icon = ""; | |
break; | |
} | |
return icon; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <stdio.h> | |
#include <string.h> | |
static uint16_t | |
get_icon(char *ext) | |
{ | |
static char ht[1024][8] = { | |
[ 935] = "1", [ 762] = "32x", [ 437] = "3ds", | |
[ 5] = "3dz", [ 851] = "7z", [ 47] = "R", | |
[ 131] = "Rmd", [ 22] = "a", [ 560] = "agb", | |
[ 724] = "ai", [ 731] = "akef", [ 129] = "art", | |
[ 11] = "atch", [ 680] = "atr", [1002] = "avi", | |
[ 766] = "bib", [ 800] = "bmp", [ 146] = "c", | |
[ 156] = "c++", [ 544] = "cdr", [ 340] = "cs", | |
[ 522] = "css", [ 213] = "csv", [ 137] = "diff", | |
[ 632] = "djvu", [ 998] = "dmg", [ 984] = "doc", | |
[ 882] = "docx", [ 922] = "elf", [ 356] = "epub", | |
[ 241] = "ext", [ 481] = "fds", [ 151] = "flac", | |
[ 414] = "flv", [ 838] = "gb", [ 664] = "gba", | |
[ 787] = "gbc", [ 295] = "gcm", [ 925] = "gcz", | |
[ 657] = "gdi", [ 519] = "gdoc", [ 180] = "gdocx", | |
[ 287] = "gen", [ 530] = "gg", [ 166] = "gif", | |
[ 6] = "git", [ 549] = "giti", [ 36] = "go", | |
[ 911] = "gpg", [ 382] = "gz", [ 652] = "gzip", | |
[ 491] = "h", [ 20] = "html", [ 423] = "ic", | |
[ 526] = "icen", [ 806] = "ico", [ 14] = "icon", | |
[ 854] = "id", [ 844] = "img", [ 272] = "info", | |
[ 945] = "inx", [ 41] = "iso", [ 281] = "jap", | |
[ 404] = "jar", [ 899] = "java", [ 110] = "jpe", | |
[ 496] = "jpeg", [1011] = "jpg", [ 791] = "js", | |
[ 394] = "kden", [ 938] = "ksh", [ 537] = "log", | |
[ 306] = "m", [ 301] = "m4a", [ 486] = "m4b", | |
[ 955] = "man", [ 240] = "md", [ 178] = "me", | |
[ 503] = "mii", [ 795] = "mk", [ 826] = "mkv", | |
[ 768] = "mov", [1015] = "mp3", [ 176] = "mp4", | |
[ 26] = "mpeg", [ 52] = "mpg", [ 339] = "ms", | |
[ 185] = "n64", [ 46] = "nds", [ 972] = "nes", | |
[ 23] = "nfo", [ 702] = "ngc", [ 850] = "ngp", | |
[ 748] = "nro", [ 120] = "nvim", [ 430] = "o", | |
[ 683] = "oc", [ 769] = "odg", [ 140] = "odp", | |
[ 979] = "ods", [ 917] = "odt", [ 671] = "ogg", | |
[ 34] = "opus", [ 482] = "org", [ 881] = "own", | |
[ 613] = "part", [ 975] = "patch", [ 949] = "pdf", | |
[ 885] = "pgp", [ 310] = "php", [ 929] = "png", | |
[ 348] = "pptx", [ 380] = "ps", [ 376] = "psd", | |
[ 228] = "pss", [ 750] = "py", [ 121] = "r", | |
[ 709] = "rar", [ 564] = "rmd", [ 898] = "rom", | |
[ 239] = "rvz", [ 901] = "sfc", [ 937] = "sgb", | |
[ 7] = "sh", [ 439] = "smc", [ 8] = "smd", | |
[ 477] = "sms", [ 315] = "so", [ 743] = "srl", | |
[ 710] = "st", [ 953] = "stea", [ 888] = "svg", | |
[ 951] = "swift", [ 157] = "tar", [ 932] = "tex", | |
[ 300] = "tif", [ 585] = "tiff", [ 319] = "torrent", | |
[ 259] = "ts", [ 337] = "txt", [ 691] = "us", | |
[ 101] = "v64", [ 48] = "vb", [ 322] = "vim", | |
[ 723] = "wav", [ 413] = "webm", [ 141] = "webp", | |
[ 928] = "wmv", [ 824] = "wud", [ 84] = "xcf", | |
[ 403] = "xls", [ 745] = "xlsx", [ 206] = "xml", | |
[ 962] = "xpm", [ 797] = "z64", [ 188] = "zip", | |
}; | |
static uint16_t icon[1024] = { | |
[ 935] = 0xf02d, [ 762] = 0xf796, [ 437] = 0xf796, | |
[ 5] = 0xf796, [ 851] = 0xf410, [ 47] = 0xfcd2, | |
[ 131] = 0xfcd2, [ 22] = 0xe624, [ 560] = 0xf796, | |
[ 724] = 0xfa58, [ 731] = 0xe615, [ 129] = 0xf71e, | |
[ 11] = 0xe728, [ 680] = 0xf796, [1002] = 0xf72a, | |
[ 766] = 0xf5b9, [ 800] = 0xf71e, [ 146] = 0xe61e, | |
[ 156] = 0xfb71, [ 544] = 0xfa58, [ 340] = 0xf81a, | |
[ 522] = 0xe749, [ 213] = 0xf714, [ 137] = 0xe728, | |
[ 632] = 0xf724, [ 998] = 0xfaed, [ 984] = 0xf718, | |
[ 882] = 0xf718, [ 922] = 0xf796, [ 356] = 0xf724, | |
[ 241] = 0xf65e, [ 481] = 0xf796, [ 151] = 0xf722, | |
[ 414] = 0xf72a, [ 838] = 0xf796, [ 664] = 0xf796, | |
[ 787] = 0xf796, [ 295] = 0xf796, [ 925] = 0xf796, | |
[ 657] = 0xf796, [ 519] = 0xf718, [ 180] = 0xf718, | |
[ 287] = 0xf796, [ 530] = 0xf796, [ 166] = 0xf71e, | |
[ 6] = 0xe702, [ 549] = 0xe702, [ 36] = 0xfcd1, | |
[ 911] = 0xf023, [ 382] = 0xf410, [ 652] = 0xf410, | |
[ 491] = 0xf0fd, [ 20] = 0xf81c, [ 423] = 0xf7f4, | |
[ 526] = 0xf023, [ 806] = 0xf71e, [ 14] = 0xf71e, | |
[ 854] = 0xf72f, [ 844] = 0xfaed, [ 272] = 0xf06a, | |
[ 945] = 0xfa58, [ 41] = 0xfaed, [ 281] = 0xf796, | |
[ 404] = 0xe256, [ 899] = 0xe256, [ 110] = 0xf71e, | |
[ 496] = 0xf71e, [1011] = 0xf71e, [ 791] = 0xf81d, | |
[ 394] = 0xf72a, [ 938] = 0xe795, [ 537] = 0xfd2c, | |
[ 306] = 0xfcd2, [ 301] = 0xf722, [ 486] = 0xf72a, | |
[ 955] = 0xf02d, [ 240] = 0xe73e, [ 178] = 0xf718, | |
[ 503] = 0xf796, [ 795] = 0xe615, [ 826] = 0xf72a, | |
[ 768] = 0xf72a, [1015] = 0xf722, [ 176] = 0xf72a, | |
[ 26] = 0xf72a, [ 52] = 0xf72a, [ 339] = 0xf718, | |
[ 185] = 0xf796, [ 46] = 0xf796, [ 972] = 0xf796, | |
[ 23] = 0xf06a, [ 702] = 0xf796, [ 850] = 0xf796, | |
[ 748] = 0xf796, [ 120] = 0xe62b, [ 430] = 0xe624, | |
[ 683] = 0xf64d, [ 769] = 0xfa58, [ 140] = 0xf1e7, | |
[ 979] = 0xf714, [ 917] = 0xf718, [ 671] = 0xf722, | |
[ 34] = 0xf722, [ 482] = 0xf718, [ 881] = 0xe609, | |
[ 613] = 0xfbf2, [ 975] = 0xe728, [ 949] = 0xf724, | |
[ 885] = 0xf023, [ 310] = 0xf81e, [ 929] = 0xf71e, | |
[ 348] = 0xf1e7, [ 380] = 0xfa58, [ 376] = 0xf71e, | |
[ 228] = 0xf796, [ 750] = 0xf81f, [ 121] = 0xfcd2, | |
[ 709] = 0xf410, [ 564] = 0xfcd2, [ 898] = 0xfaed, | |
[ 239] = 0xf796, [ 901] = 0xf796, [ 937] = 0xf796, | |
[ 7] = 0xe795, [ 439] = 0xf796, [ 8] = 0xf796, | |
[ 477] = 0xf796, [ 315] = 0xe624, [ 743] = 0xf796, | |
[ 710] = 0xf796, [ 953] = 0xf1b6, [ 888] = 0xfa58, | |
[ 951] = 0xfbe3, [ 157] = 0xf410, [ 932] = 0xf718, | |
[ 300] = 0xf71e, [ 585] = 0xf71e, [ 319] = 0xfbf2, | |
[ 259] = 0xfbe4, [ 337] = 0xf718, [ 691] = 0xfc58, | |
[ 101] = 0xf796, [ 48] = 0xf796, [ 322] = 0xe62b, | |
[ 723] = 0xf722, [ 413] = 0xf72a, [ 141] = 0xf71e, | |
[ 928] = 0xf72a, [ 824] = 0xf796, [ 84] = 0xf71e, | |
[ 403] = 0xf714, [ 745] = 0xf714, [ 206] = 0xfa9e, | |
[ 962] = 0xf71e, [ 797] = 0xf796, [ 188] = 0xf410, | |
}; | |
uint64_t h = 91772; | |
char *s = ext; | |
while (*s) { | |
h ^= *s++ & 0xff; | |
h *= 1111111111111111111ULL; | |
} | |
int i = h >> (64 - 10); | |
if (ht[i][0] && !strcmp(ht[i], ext)) { | |
return icon[i]; | |
} | |
return 0; | |
} | |
int main(void) | |
{ | |
printf("U+%04x\n", get_icon("foo")); | |
printf("U+%04x\n", get_icon("torrent")); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define N (int)(sizeof(ext)/sizeof(*ext)) | |
#define B 10 | |
static struct { | |
char *e; | |
int cp; | |
} ext[] = { | |
{"1", 0xf02d}, {"32x", 0xf796}, {"3ds", 0xf796}, | |
{"3dz", 0xf796}, {"7z", 0xf410}, {"R", 0xfcd2}, | |
{"Rmd", 0xfcd2}, {"a", 0xe624}, {"agb", 0xf796}, | |
{"ai", 0xfa58}, {"akef", 0xe615}, {"art", 0xf71e}, | |
{"atch", 0xe728}, {"atr", 0xf796}, {"avi", 0xf72a}, | |
{"bib", 0xf5b9}, {"bmp", 0xf71e}, {"c", 0xe61e}, | |
{"c++", 0xfb71}, {"cdr", 0xfa58}, {"cs", 0xf81a}, | |
{"css", 0xe749}, {"csv", 0xf714}, {"diff", 0xe728}, | |
{"djvu", 0xf724}, {"dmg", 0xfaed}, {"doc", 0xf718}, | |
{"docx", 0xf718}, {"elf", 0xf796}, {"epub", 0xf724}, | |
{"ext", 0xf65e}, {"fds", 0xf796}, {"flac", 0xf722}, | |
{"flv", 0xf72a}, {"gb", 0xf796}, {"gba", 0xf796}, | |
{"gbc", 0xf796}, {"gcm", 0xf796}, {"gcz", 0xf796}, | |
{"gdi", 0xf796}, {"gdoc", 0xf718}, {"gdocx", 0xf718}, | |
{"gen", 0xf796}, {"gg", 0xf796}, {"gif", 0xf71e}, | |
{"git", 0xe702}, {"giti", 0xe702}, {"go", 0xfcd1}, | |
{"gpg", 0xf023}, {"gz", 0xf410}, {"gzip", 0xf410}, | |
{"h", 0xf0fd}, {"html", 0xf81c}, {"ic", 0xf7f4}, | |
{"icen", 0xf023}, {"ico", 0xf71e}, {"icon", 0xf71e}, | |
{"id", 0xf72f}, {"img", 0xfaed}, {"info", 0xf06a}, | |
{"inx", 0xfa58}, {"iso", 0xfaed}, {"jap", 0xf796}, | |
{"jar", 0xe256}, {"java", 0xe256}, {"jpe", 0xf71e}, | |
{"jpeg", 0xf71e}, {"jpg", 0xf71e}, {"js", 0xf81d}, | |
{"kden", 0xf72a}, {"ksh", 0xe795}, {"log", 0xfd2c}, | |
{"m", 0xfcd2}, {"m4a", 0xf722}, {"m4b", 0xf72a}, | |
{"man", 0xf02d}, {"md", 0xe73e}, {"me", 0xf718}, | |
{"mii", 0xf796}, {"mk", 0xe615}, {"mkv", 0xf72a}, | |
{"mov", 0xf72a}, {"mp3", 0xf722}, {"mp4", 0xf72a}, | |
{"mpeg", 0xf72a}, {"mpg", 0xf72a}, {"ms", 0xf718}, | |
{"n64", 0xf796}, {"nds", 0xf796}, {"nes", 0xf796}, | |
{"nfo", 0xf06a}, {"ngc", 0xf796}, {"ngp", 0xf796}, | |
{"nro", 0xf796}, {"nvim", 0xe62b}, {"o", 0xe624}, | |
{"oc", 0xf64d}, {"odg", 0xfa58}, {"odp", 0xf1e7}, | |
{"ods", 0xf714}, {"odt", 0xf718}, {"ogg", 0xf722}, | |
{"opus", 0xf722}, {"org", 0xf718}, {"own", 0xe609}, | |
{"part", 0xfbf2}, {"patch", 0xe728}, {"pdf", 0xf724}, | |
{"pgp", 0xf023}, {"php", 0xf81e}, {"png", 0xf71e}, | |
{"pptx", 0xf1e7}, {"ps", 0xfa58}, {"psd", 0xf71e}, | |
{"pss", 0xf796}, {"py", 0xf81f}, {"r", 0xfcd2}, | |
{"rar", 0xf410}, {"rmd", 0xfcd2}, {"rom", 0xfaed}, | |
{"rvz", 0xf796}, {"sfc", 0xf796}, {"sgb", 0xf796}, | |
{"sh", 0xe795}, {"smc", 0xf796}, {"smd", 0xf796}, | |
{"sms", 0xf796}, {"so", 0xe624}, {"srl", 0xf796}, | |
{"st", 0xf796}, {"stea", 0xf1b6}, {"svg", 0xfa58}, | |
{"swift", 0xfbe3}, {"tar", 0xf410}, {"tex", 0xf718}, | |
{"tif", 0xf71e}, {"tiff", 0xf71e}, {"torrent", 0xfbf2}, | |
{"ts", 0xfbe4}, {"txt", 0xf718}, {"us", 0xfc58}, | |
{"v64", 0xf796}, {"vb", 0xf796}, {"vim", 0xe62b}, | |
{"wav", 0xf722}, {"webm", 0xf72a}, {"webp", 0xf71e}, | |
{"wmv", 0xf72a}, {"wud", 0xf796}, {"xcf", 0xf71e}, | |
{"xls", 0xf714}, {"xlsx", 0xf714}, {"xml", 0xfa9e}, | |
{"xpm", 0xf71e}, {"z64", 0xf796}, {"zip", 0xf410}, | |
}; | |
static unsigned long long | |
hash(char *s, unsigned long long k) | |
{ | |
unsigned long long h = k; | |
while (*s) { | |
h ^= *s++ & 0xff; | |
h *= 1111111111111111111ULL; | |
} | |
return h; | |
} | |
int main(void) | |
{ | |
//#pragma omp parallel for | |
for (int k = 0; k < 0x7fffffff; k++) { | |
int valid = 1; | |
char seen[1<<B] = {0}; | |
for (int i = 0; i < N; i++) { | |
unsigned long long h = hash(ext[i].e, k); | |
if (seen[h>>(64-B)]) { | |
valid = 0; | |
break; | |
} | |
seen[h>>(64-B)] = 1; | |
} | |
if (valid) { | |
printf("static char ht[%d][8] = {\n", 1<<B); | |
for (int i = 0; i < N; i++) { | |
unsigned long long h = hash(ext[i].e, k); | |
printf("\t[%4d] = \"%s\",\n", (int)(h>>(64-B)), ext[i].e); | |
} | |
printf("};\n"); | |
printf("static uint16_t icon[%d] = {\n", 1<<B); | |
for (int i = 0; i < N; i++) { | |
unsigned long long h = hash(ext[i].e, k); | |
printf("\t[%4d] = 0x%04x,\n", (int)(h>>(64-B)), ext[i].cp); | |
} | |
printf("};\n"); | |
printf("int k = %d;\n", k); | |
return 0; | |
} | |
} | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment