7 /* Default Pixmap path */
9 #define PIXMAP_PATH "/usr/share/applets/pixmaps/"
10 #define PIXMAP_DEFAULT "/usr/share/applets/pixmaps/mail.png"
13 static char *make_pixmap_path(char *dest
, char *src
, size_t n
)
16 char md5_str
[16 * 2 + 1];
20 /* PIXMAP_PATH + MD5_STR + '.png' + '\0' */
21 const size_t i
= strlen(PIXMAP_PATH
) + (2 * 16) + 4 + 1;
25 fprintf(stderr
, "%s - Buffer too short! [%lu/%lu]\n",
26 __func__
, (unsigned long) n
, (unsigned long) i
);
33 fprintf(stderr
, "%s - MALLOC %s\n", __func__
, strerror(errno
));
38 memset(md5_str
, 0, 16*2 +1);
40 for (j
= 0; j
< 16; j
++) {
41 snprintf(p
, 3, "%02x", (unsigned char) src
[j
]);
44 snprintf(icon
, i
, "%s%s.png", PIXMAP_PATH
, md5_str
);
46 fprintf(stderr
, "%s - PIXMAP_PATH:\"%s\"\n", __func__
, PIXMAP_PATH
);
51 char *icon_get_path(char *filename
)
55 icon
= make_pixmap_path(NULL
, filename
, 0);
57 if (access(icon
, F_OK
| R_OK
) != 0) {
59 fprintf(stderr
, "%s - ACCESS:%s %s\n", __func__
, icon
, strerror(errno
));
62 icon
= PIXMAP_DEFAULT
;
67 fprintf(stderr
, "%s - icon:\"%s\"\n", __func__
, icon
);
72 void icon_free_path(char *icon
)
74 if ((icon
) && (icon
!= (char *) &PIXMAP_DEFAULT
)) {