Commit 49b2967e9b4b6e44b1d7c138983889e48a9ef80c

Authored by Silvan Calarco
1 parent 4199fc7d62
Exists in master

Use url in FAVICON_SEARCH_PREFIX to get favicon url for sites

Default configuration pointing to google service
Fallfack to <url>/favicon.ico if FAVICON_SEARCH_PREFIX is not set

Showing 3 changed files with 21 additions and 12 deletions Side-by-side Diff

... ... @@ -34,6 +34,10 @@
34 34 # (default: ARCHS=i586)
35 35 #
36 36 #ARCHS = i586
  37 +#
  38 +# FAVICON_SEARCH_PREFIX:
  39 +# external prefix url to service providing sites favicons
  40 +FAVICON_SEARCH_PREFIX="http://www.google.com/s2/favicons?domain="
37 41  
38 42 #[maintainers]
39 43 # put maintainer list with aliases here
... ... @@ -255,6 +255,9 @@
255 255 } else if (!strcmp(vartok, "URL_DIR")) {
256 256 configdefaults.url_dir =
257 257 (char *) strdup(valuetok);
  258 + } else if (!strcmp(vartok, "FAVICON_SEARCH_PREFIX")) {
  259 + configdefaults.favicon_search_prefix =
  260 + (char *) strdup(valuetok);
258 261 } else if (!strcmp(vartok, "ARCHS")) {
259 262 vartok = (char *) strtok(valuetok, " ");
260 263 i = 0;
261 264  
262 265  
263 266  
264 267  
... ... @@ -621,26 +624,27 @@
621 624 return(i);
622 625 }
623 626  
624   -#define favicon_url_prefix "http://g.etfv.co/"
625   -
626 627 int
627 628 get_favicon_from_url(const char* url,char *buf,int bufsize) {
628 629  
629 630 int i=0,l=0;
630 631  
631   - strncpy(buf, favicon_url_prefix, bufsize);
  632 + if (configdefaults.favicon_search_prefix != NULL) {
  633 + snprintf(buf, bufsize, "%s%s", configdefaults.favicon_search_prefix, url);
  634 + } else {
  635 + snprintf(buf, bufsize, "%s", url);
632 636  
633   - /* expecting urls in the form http://address/... */
634   - if (url) {
635   - while ((i<bufsize) && url[i]) {
636   - if (url[i] == '/') {
637   - l++;
638   - if (l == 3) break;
639   - }
  637 + /* expecting urls in the form http://address/... */
  638 + while ((i<bufsize) && buf[i]) {
  639 + if (buf[i] == '/') {
  640 + l++;
  641 + if (l == 3) break;
  642 + }
640 643 i++;
641 644 }
  645 + buf[i] = 0;
  646 + snprintf(&buf[i], bufsize - l, "/favicon.ico");
642 647 }
643   - strncpy(&buf[strlen(buf)], url, i);
644 648 return 0;
645 649 }
src/include/distromatic.h
... ... @@ -18,6 +18,7 @@
18 18 char *url_prefix;
19 19 char *url_search_prefix;
20 20 char *url_dir;
  21 + char *favicon_search_prefix;
21 22 char *arch[ARCHS_MAX];
22 23 };
23 24