Exemplo n.º 1
0
int
xps_open_stream(xps_context **ctxp, fz_stream *file)
{
	xps_context *ctx;
	int code;

	ctx = fz_malloc(file->ctx, sizeof(xps_context));
	memset(ctx, 0, sizeof(xps_context));

	ctx->ctx = file->ctx;
	ctx->file = fz_keep_stream(file);

	code = xps_find_and_read_zip_dir(ctx);
	if (code < 0)
	{
		xps_free_context(ctx);
		return fz_error_note(file->ctx, code, "cannot read zip central directory");
	}

	code = xps_read_page_list(ctx);
	if (code)
	{
		xps_free_context(ctx);
		return fz_error_note(file->ctx, code, "cannot read page list");
	}

	*ctxp = ctx;
	return fz_okay;
}
Exemplo n.º 2
0
xps_document *
xps_open_document_with_stream(fz_context *ctx, fz_stream *file)
{
	xps_document *doc;

	doc = fz_malloc_struct(ctx, xps_document);
	xps_init_document(ctx, doc);

	fz_try(ctx)
	{
		doc->zip = fz_open_archive_with_stream(ctx, file);
		xps_read_page_list(ctx, doc);
	}
	fz_catch(ctx)
	{
		xps_close_document(ctx, doc);
		fz_rethrow(ctx);
	}

	return doc;
}
Exemplo n.º 3
0
static xps_document *
xps_open_document_with_directory(fz_context *ctx, const char *directory)
{
	xps_document *doc;

	doc = fz_malloc_struct(ctx, xps_document);
	xps_init_document(ctx, doc);
	doc->zip = fz_open_directory(ctx, directory);

	fz_try(ctx)
	{
		xps_read_page_list(ctx, doc);
	}
	fz_catch(ctx)
	{
		xps_close_document(ctx, doc);
		fz_rethrow(ctx);
	}

	return doc;
}
Exemplo n.º 4
0
static int
xps_open_directory(fz_context *fctx, xps_context **ctxp, char *directory)
{
	xps_context *ctx;
	int code;

	ctx = fz_malloc(fctx, sizeof(xps_context));
	memset(ctx, 0, sizeof(xps_context));

	ctx->directory = fz_strdup(fctx, directory);
	ctx->ctx = fctx;

	code = xps_read_page_list(ctx);
	if (code)
	{
		xps_free_context(ctx);
		return fz_error_note(fctx, code, "cannot read page list");
	}

	*ctxp = ctx;
	return fz_okay;
}