Esempio n. 1
0
static bool load_template(BlogRef const blog, strarg_t const name, TemplateRef *const out) {
	assert(out);
	assert(blog->dir);
	str_t path[PATH_MAX];
	int rc = snprintf(path, PATH_MAX, "%s/template/%s", blog->dir, name);
	if(rc < 0 || rc >= PATH_MAX) return false;
	TemplateRef t = TemplateCreateFromPath(path);
	if(!t) {
		fprintf(stderr, "Blog couldn't load template at %s\n", path);
		return false;
	}
	*out = t;
	return true;
}
Esempio n. 2
0
static bool load_template(BlogRef const blog, strarg_t const name, TemplateRef *const out) {
	assert(out);
	assert(blog->dir);
	str_t path[PATH_MAX];
	int rc = snprintf(path, sizeof(path), "%s/template/%s", blog->dir, name);
	if(rc < 0 || rc >= sizeof(path)) return false;
	TemplateRef t = TemplateCreateFromPath(path);
	if(!t) {
		alogf("Couldn't load blog template at '%s'\n", path);
		alogf("(Try reinstalling the resource files.)\n");
		return false;
	}
	*out = t;
	return true;
}
Esempio n. 3
0
// TODO: Basically identical to version in RSSServer.c.
static int load_template(BlogRef const blog, strarg_t const name, TemplateRef *const out) {
	assert(out);
	assert(blog->dir);
	str_t path[PATH_MAX];
	int rc = snprintf(path, sizeof(path), "%s/template/%s", blog->dir, name);
	if(rc < 0) return rc; // TODO: snprintf(3) error reporting?
	if(rc >= sizeof(path)) return UV_ENAMETOOLONG;
	TemplateRef t = NULL;
	rc = TemplateCreateFromPath(path, &t);
	if(rc < 0) {
		alogf("Error loading template at '%s': %s\n", path, uv_strerror(rc));
		if(UV_ENOENT == rc) alogf("(Try reinstalling the resource files.)\n");
		return rc;
	}
	*out = t; t = NULL;
	return 0;
}