/* create new framebuffer face and cause it to be loaded to check its ok */ static fb_faceid_t * fb_new_face(const char *option, const char *resname, const char *fontname) { fb_faceid_t *newf; FT_Error error; FT_Face aface; char buf[PATH_MAX]; newf = calloc(1, sizeof(fb_faceid_t)); if (option != NULL) { newf->fontfile = strdup(option); } else { filepath_sfind(respaths, buf, fontname); newf->fontfile = strdup(buf); } error = FTC_Manager_LookupFace(ft_cmanager, (FTC_FaceID)newf, &aface); if (error) { LOG(("Could not find font face %s (code %d)\n", fontname, error)); free(newf); newf = NULL; } return newf; }
/* exported interface documented in filepath.h */ char *filepath_sfinddef(char **respathv, char *filepath, const char *filename, const char *def) { char t[PATH_MAX]; char *ret; if ((respathv == NULL) || (respathv[0] == NULL) || (filepath == NULL)) return NULL; ret = filepath_sfind(respathv, filepath, filename); if ((ret == NULL) && (def != NULL)) { /* search failed, return the path specified */ ret = filepath; if (def[0] == '~') { snprintf(t, PATH_MAX, "%s/%s/%s", getenv("HOME"), def + 1, filename); } else { snprintf(t, PATH_MAX, "%s/%s", def, filename); } if (realpath(t, ret) == NULL) { strcpy(ret, t); } } return ret; }
/** * Translate resource to full url. * * Transforms a resource: path into a full URL. The returned URL * is used as the target for a redirect. The caller takes ownership of * the returned nsurl including unrefing it when finished with it. * * \param path The path of the resource to locate. * \return A string containing the full URL of the target object or * NULL if no suitable resource can be found. */ static nsurl *get_resource_url(const char *path) { char buf[PATH_MAX]; nsurl *url = NULL; if (strcmp(path, "favicon.ico") == 0) path = "favicon.png"; netsurf_path_to_nsurl(filepath_sfind(respaths, buf, path), &url); return url; }
nsurl *gui_get_resource_url(const char *path) { char buf[PATH_MAX]; char *raw; nsurl *url = NULL; raw = path_to_url(filepath_sfind(respaths, buf, path)); if (raw != NULL) { nsurl_create(raw, &url); free(raw); } return url; }
nsurl *gui_get_resource_url(const char *path) { char buf[PATH_MAX]; char *raw; nsurl *url = NULL; if (strcmp(path, "favicon.ico") == 0) path = "favicon.png"; raw = path_to_url(filepath_sfind(respaths, buf, path)); LOG(("Findfile gui: %s", raw)); if (raw != NULL) { nsurl_create(raw, &url); free(raw); } return url; }
/* exported interface documented in filepath.h */ char *filepath_find(char **respathv, const char *filename) { char *ret; char *filepath; if ((respathv == NULL) || (respathv[0] == NULL)) return NULL; filepath = malloc(PATH_MAX); if (filepath == NULL) return NULL; ret = filepath_sfind(respathv, filepath, filename); if (ret == NULL) free(filepath); return ret; }
nsurl *gui_get_resource_url(const char *path) { char buf[PATH_MAX]; char *raw; nsurl *url = NULL; /* default.css -> gtkdefault.css */ if (strcmp(path, "default.css") == 0) path = "gtkdefault.css"; /* favicon.ico -> favicon.png */ if (strcmp(path, "favicon.ico") == 0) path = "favicon.png"; raw = path_to_url(filepath_sfind(respaths, buf, path)); if (raw != NULL) { nsurl_create(raw, &url); free(raw); } return url; }