Пример #1
0
fz_document *
fz_open_document(fz_context *ctx, char *filename)
{
	char *ext = strrchr(filename, '.');

	if (ext)
	{
		if (!fz_strcasecmp(ext, ".xps") || !fz_strcasecmp(ext, ".rels"))
			return (fz_document*) xps_open_document(ctx, filename);
		if (!fz_strcasecmp(ext, ".cbz") || !fz_strcasecmp(ext, ".zip"))
			return (fz_document*) cbz_open_document(ctx, filename);
		if (!fz_strcasecmp(ext, ".pdf"))
			return (fz_document*) pdf_open_document(ctx, filename);
	}

	/* last guess: pdf */
	return (fz_document*) pdf_open_document(ctx, filename);
}
Пример #2
0
fz_document *
fz_open_document(fz_context *ctx, char *filename)
{
	char *ext = strrchr(filename, '.');
	if (ext && (!fz_strcasecmp(ext, ".xps") || !fz_strcasecmp(ext, ".rels")))
		return (fz_document*) xps_open_document(ctx, filename);
	if (ext && !fz_strcasecmp(ext, ".cbz"))
		return (fz_document*) cbz_open_document(ctx, filename);
#if 0
	/* We used to only open pdf files if they ended in .pdf. For now,
	 * until we move to detecting filetypes by their content, we disable
	 * this code, and assume that any file that hasn't matched an
	 * extension already, is a PDF. */
	if (ext && !fz_strcasecmp(ext, ".pdf"))
		return (fz_document*) pdf_open_document(ctx, filename);
	fz_throw(ctx, "unknown document type: '%s'", filename);
	return NULL;
#else
	return (fz_document*) pdf_open_document(ctx, filename);
#endif
}