Pass command line parameters for shared object renderer to command line convert struct

This commit is contained in:
Mario Hüttel 2019-11-15 20:50:46 +01:00
parent f02a720f99
commit c186d3cdb3
3 changed files with 33 additions and 16 deletions

View File

@ -56,7 +56,7 @@ static int create_renderers(char **renderers,
char **output_file_names,
gboolean tex_layers,
gboolean tex_standalone,
const char *so_path,
const struct external_renderer_params *ext_params,
GList **renderer_list,
LayerSettings *layer_settings)
{
@ -100,11 +100,11 @@ static int create_renderers(char **renderers,
} else if (!strcmp(current_renderer, "svg")) {
output_renderer = GDS_RENDER_OUTPUT_RENDERER(cairo_renderer_new_svg());
} else if (!strcmp(current_renderer, "ext")) {
if (!so_path) {
if (!ext_params->so_path) {
fprintf(stderr, _("Please specify shared object for external renderer. Will ignore this renderer.\n"));
continue;
}
output_renderer = GDS_RENDER_OUTPUT_RENDERER(external_renderer_new_with_so(so_path));
output_renderer = GDS_RENDER_OUTPUT_RENDERER(external_renderer_new_with_so(ext_params->so_path));
} else {
continue;
}
@ -138,7 +138,7 @@ int command_line_convert_gds(const char *gds_name,
char **renderers,
char **output_file_names,
const char *layer_file,
const char *so_path,
struct external_renderer_params *ext_param,
gboolean tex_standalone,
gboolean tex_layers,
double scale)
@ -165,7 +165,7 @@ int command_line_convert_gds(const char *gds_name,
/* Create renderers */
if (create_renderers(renderers, output_file_names, tex_layers, tex_standalone,
so_path, &renderer_list, layer_sett))
ext_param, &renderer_list, layer_sett))
goto ret_destroy_layer_mapping;

View File

@ -33,6 +33,21 @@
#include <glib.h>
/**
* @brief External renderer paramameters to command line renderer
*/
struct external_renderer_params {
/**
* @brief Path to shared object
*/
char *so_path;
/**
* @brief Command line parameters given
*/
char *cli_params;
};
/**
* @brief Convert GDS according to command line parameters
* @param gds_name Path to GDS File
@ -40,7 +55,7 @@
* @param renderers Renderer ids
* @param output_file_names Output file names
* @param layer_file Layer mapping file
* @param so_path Shared object
* @param ext_params Settings for external library renderer
* @param tex_standalone Standalone TeX
* @param tex_layers TeX OCR layers
* @param scale Scale value
@ -51,7 +66,7 @@ int command_line_convert_gds(const char *gds_name,
char **renderers,
char **output_file_names,
const char *layer_file,
const char *so_path,
struct external_renderer_params *ext_param,
gboolean tex_standalone,
gboolean tex_layers,
double scale);

20
main.c
View File

@ -261,12 +261,14 @@ int main(int argc, char **argv)
gchar **output_paths = NULL;
gchar *mappingname = NULL;
gchar *cellname = NULL;
gchar *render_lib_param_string = NULL;
gchar **renderer_args = NULL;
gboolean version = FALSE, pdf_standalone = FALSE, pdf_layers = FALSE;
gchar *custom_library_path = NULL;
int scale = 1000;
int app_status = 0;
struct external_renderer_params so_render_params;
so_render_params.so_path = NULL;
so_render_params.cli_params = NULL;
bindtextdomain(GETTEXT_PACKAGE, LOCALEDATADIR "/locale");
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
@ -283,9 +285,9 @@ int main(int argc, char **argv)
{"cell", 'c', 0, G_OPTION_ARG_STRING, &cellname, _("Cell to render"), "NAME" },
{"tex-standalone", 'a', 0, G_OPTION_ARG_NONE, &pdf_standalone, _("Create standalone TeX"), NULL },
{"tex-layers", 'l', 0, G_OPTION_ARG_NONE, &pdf_layers, _("Create PDF Layers (OCG)"), NULL },
{"custom-render-lib", 'P', 0, G_OPTION_ARG_FILENAME, &custom_library_path,
{"custom-render-lib", 'P', 0, G_OPTION_ARG_FILENAME, &so_render_params.so_path,
_("Path to a custom shared object, that implements the necessary rendering functions"), "PATH"},
{"render-lib-params", 'W', 0, G_OPTION_ARG_STRING, &render_lib_param_string,
{"render-lib-params", 'W', 0, G_OPTION_ARG_STRING, &so_render_params.cli_params,
_("Argument string passed to render lib"), NULL},
{NULL, 0, 0, 0, NULL, NULL, NULL}
};
@ -321,7 +323,7 @@ int main(int argc, char **argv)
app_status =
command_line_convert_gds(gds_name, cellname, renderer_args, output_paths, mappingname,
custom_library_path, pdf_standalone, pdf_layers, scale);
&so_render_params, pdf_standalone, pdf_layers, scale);
} else {
app_status = start_gui(argc, argv);
@ -340,10 +342,10 @@ ret_status:
g_free(mappingname);
if (cellname)
free(cellname);
if (custom_library_path)
free(custom_library_path);
if (render_lib_param_string)
g_free(render_lib_param_string);
if (so_render_params.so_path)
free(so_render_params.so_path);
if (so_render_params.cli_params)
g_free(so_render_params.cli_params);
return app_status;
}