dkfigco.c File Reference

Conversion job module. More...

#include "dkfig.h"

Include dependency graph for dkfigco.c:


Defines

#define DKFIGCO_C   1
 Inside the dkfigco module.
#define SYSCONFDIR   "/etc"
 System configuration directory (definition).

Functions

static void cleanup_options_iterator (dk_storage_t *s, dk_storage_iterator_t *i)
 Cleanup options storage.
void dkfig_co_cleanup (dk_fig_conversion *c)
 Clean up conversion job structure before releasing the memory.
void dkfig_co_delete (dk_fig_conversion *c)
 Cleanup up and release conversion job structure.
static void initialize_options_storage (dk_fig_conversion *c, int what)
 Initialize options storage.
static int set_tex_filenames (dk_fig_conversion *c)
 Find names for temporary files.
int dkfig_co_init (dk_fig_conversion *c, dk_app_t *a)
 Initialize newly created conversion job structure, use default values and preferences obtained from.
dk_fig_conversiondkfig_co_new (dk_app_t *a)
 Allocate new dk_fig_conversion structure and initialize it.
static unsigned long check_bool_opts (unsigned long a, char *p, unsigned long f, int d)
 Set/reset one bit in an unsigned long depending on the string.
static int get_base_driver (char *n)
 Get base driver number.
static void add_opt (dk_fig_conversion *c, unsigned long on, char *p, int *bck)
 Add an option.
static void set_driver (dk_fig_conversion *c, char *drn, int *bck)
 Set driver name.
int dkfig_co_apply_args (dk_fig_conversion *c, int argc, char **argv)
 Apply command line arguments to conversion job.
void dkfig_co_showconf_app (dk_fig_conversion *c)
 Show current configuration.
int dkfig_co_configure_app (dk_fig_conversion *c)
 Save current configuration.
static void establish_base_driver_name (dk_fig_conversion *c)
 Find base driver name.
static int add_option_line (dk_fig_conversion *c, char *l, unsigned long ln, int st)
 Process one line from configuration file.
static int dkfig_co_load_configuration (dk_fig_conversion *c)
 Read configuration file and load contents to the storages.
static size_t largest_of (dk_storage_t *sto, dk_storage_iterator_t *it)
 Find largest line size in a storage.
static void set_lcfge (dk_fig_conversion *c)
 Find largest line size for all option storages.
int dkfig_co_add_stream (dk_fig_conversion *c)
 Add input stream contents to drawing.
static int dkfig_co_out_to_stream (dk_fig_conversion *c)
 Run the conversion, write output.
static int run_for_streams (dk_fig_conversion *c)
 Run for opened streams.
static int run_for_stdio (dk_fig_conversion *c)
 Run as filter (standard input, standard output).
static char * find_fig_suffix (char *n)
 Find suffix of input file to chech whether the file is plain text or compressed.
static int run_with_ofn2 (dk_fig_conversion *c)
 Open output stream and continue.
static int run_with_istream (dk_fig_conversion *c)
 Run with opened input stream.
static int run_with_ifn2 (dk_fig_conversion *c)
 Run with input file name (wildcards are resolved).
static int run_for_filenames (dk_fig_conversion *c)
 Run with filenames possibly containing wildcards.
static void save_co_settings (dk_fig_conversion *cd, dk_fig_conversion *cs)
 Save conversion job settings.
static int run_for_directory (dk_fig_conversion *c)
 Run for a directory, convert all Fig files found.
static int lets_go_now (dk_fig_conversion *c)
 Check whether running on files or on a directory, run the conversion(s).
int dkfig_co_run (dk_fig_conversion *c)
 Load configuration file, process options and run conversion.
int dkfig_co_show_config_file (dk_fig_conversion *c)
 Show the contents of the used configuration file on standard output.
int dkfig_co_write_config_file (dk_fig_conversion *c)
 Save a configuration file read from standard input as user-specific configuration file.

Variables

static char default_config_filename [] = { "/etc" "/fig2vect.cfg" }
 System configuration directory (string constant).
static char short_config_filename [] = { "fig2vect.cfg" }
 Confiration file name.
static char str_r [] = { "r" }
 File open mode.
static char pk_language [] = { "/output-language" }
 Preference key to retrieve the output language.
static char pk_make [] = { "/make" }
 Preference key to retrieve make-mode flag.
static char pk_linelgt [] = { "/line-length" }
 Preference key to retrieve maximum line length.
static char pk_utf8 [] = { "/utf-8" }
 Preference key to retrieve UTF-8 handling flag.
static char pv_empty [] = { "" }
 Empty string, used when storing preferences.
static char pk_shdir [] = { "/dir/shared" }
 Preference key to retrieve shared directory.
static char str_uc2l [] = { "/uc2lat-t" }
 Preference key to retrieve UTF-8 to LaTeX tables directory.
static char pk_alph [] = { "/pdf/suppress-alpha-info" }
 Preference key to retrieve flag for suppressing info about alpha channels.
static char * bool_val [] = { "off", "on", NULL }
 String to test values for on or off.
static char * output_suffixes []
 Suffixes for different output file types.
static char * longopt_keywords []
 Kkeywords for long options.
static int have_fncaseins
 Flag: Have case insensitive file names.
static dk_key_value_t kv []
 Key/value pairs to create the message array.
static size_t szkv = sizeof(kv)/sizeof(dk_key_value_t)
 Number of entries in the kv table.
static char * figsuffixes []
 Suffixes for XFig files we are willing to read.
static char * suffixes []
 Compression suffixes we can possibly handle.
static char * base_driver_names []
 Driver base names.
static char string_stdin [] = { "<<<stdin>>>" }
 File name standard input.
static char string_stdout [] = { "<<<stdout>>>" }
 File name for standard output.
static char string_dot [] = { "." }
 Dot (string constant used to find the file name suffix).
static size_t max_line_length
 Maximum input line length.
static unsigned long builtin_default_options1
 Builtin default options (1).
static unsigned long builtin_default_options2
 Builtin default options(2).
static char str_conv_format [] = { "f2v_%lu.tex" }
 File name format for temporary files: *.tex.
static char str_conv_dvi [] = { "f2v_%lu.dvi" }
 File name format for temporary files: *.dvi.
static char str_conv_ps [] = { "f2v_%lu.ps" }
 File name format for temporary files: *.ps.
static char str_conv_log [] = { "f2v_%lu.log" }
 File name format for temporary files: *.log.
static char str_conv_aux [] = { "f2v_%lu.aux" }
 File name format for temporary files: *.aux.
static char string_table_name [] = { "fig2vect" }
 Name of string table to load for application.
static char default_write_mode [] = { "wb" }
 Mode string to open files for binary writing.
static char text_write_mode [] = { "w" }
 Mode string to open files for writing.
static char sccs_id [] = { "@(#)dkfigco.ctr 1.137 11/23/09" }
 SCCS ID.

Detailed Description

Conversion job module.


Function Documentation

static void add_opt ( dk_fig_conversion c,
unsigned long  on,
char *  p,
int *  bck 
) [static]

Add an option.

Parameters:
c Conversion job structure.
on Option number.
p Option text (key=value).
bck Pointer to variable for error code.

static int add_option_line ( dk_fig_conversion c,
char *  l,
unsigned long  ln,
int  st 
) [static]

Process one line from configuration file.

Parameters:
c Conversion job structure.
l Line text.
ln Line number.
st Storage selector (0=global options, 1=base driver options, 2=driver options).
Returns:
1 on success, 0 on error.

static unsigned long check_bool_opts ( unsigned long  a,
char *  p,
unsigned long  f,
int  d 
) [static]

Set/reset one bit in an unsigned long depending on the string.

  • p retrieved from the preference system.
    Parameters:
    a Old option value.
    p String to inspcect.
    f Flag bit value to set or reset.
    d Default value.
    Returns:
    New flag set.

static void cleanup_options_iterator ( dk_storage_t *  s,
dk_storage_iterator_t *  i 
) [static]

Cleanup options storage.

Release memory for options, storage and iterator of a conversion structure. This function is invoked from dkfig_co_cleanup().

Parameters:
s Storage.
i Storage iterator.

int dkfig_co_add_stream ( dk_fig_conversion c  ) 

Add input stream contents to drawing.

Parameters:
c Conversion job structure
Returns:
1 on success, 0 on error.

int dkfig_co_apply_args ( dk_fig_conversion c,
int  argc,
char **  argv 
)

Apply command line arguments to conversion job.

Parameters:
c Conversion job structure.
argc Number of command line arguments.
argv Command line arguments array.
Returns:
1 on success, 0 on error.

void dkfig_co_cleanup ( dk_fig_conversion c  ) 

Clean up conversion job structure before releasing the memory.

This function is invoked from dkfig_co_delete() or dkfig_co_new().

Parameters:
c Conversion job structure.

int dkfig_co_configure_app ( dk_fig_conversion c  ) 

Save current configuration.

Parameters:
c Conversion job structure.
Returns:
1 on success, 0 on error.

void dkfig_co_delete ( dk_fig_conversion c  ) 

Cleanup up and release conversion job structure.

Parameters:
c Conversion job structure.

int dkfig_co_init ( dk_fig_conversion c,
dk_app_t *  a 
)

Initialize newly created conversion job structure, use default values and preferences obtained from.

  • a.
    Parameters:
    c New conversion job structure.
    a Application structure.
    Returns:
    1 on success, 0 on error.

static int dkfig_co_load_configuration ( dk_fig_conversion c  )  [static]

Read configuration file and load contents to the storages.

Parameters:
c Conversion job structure.
Returns:
1 on success, 0 on error.

dk_fig_conversion* dkfig_co_new ( dk_app_t *  a  ) 

Allocate new dk_fig_conversion structure and initialize it.

Parameters:
a Application structure.
Returns:
Pointer to new conversion job structure on success, NULL on error.

static int dkfig_co_out_to_stream ( dk_fig_conversion c  )  [static]

Run the conversion, write output.

This is the place to add new drivers.

Parameters:
c Conversion job structure.
Returns:
1 on success, 0 on error.

int dkfig_co_run ( dk_fig_conversion c  ) 

Load configuration file, process options and run conversion.

Parameters:
c Conversion job structure.
Returns:
1 on success, 0 on error.

int dkfig_co_show_config_file ( dk_fig_conversion c  ) 

Show the contents of the used configuration file on standard output.

A GUI wrapped around fig2vect may run "fig2vect --configuration-file" to see the driver configurations and the configuration settings.

Parameters:
c Conversion job structure.
Returns:
1 on success, 0 on error.

void dkfig_co_showconf_app ( dk_fig_conversion c  ) 

Show current configuration.

Parameters:
c Configuration job structure.

int dkfig_co_write_config_file ( dk_fig_conversion c  ) 

Save a configuration file read from standard input as user-specific configuration file.

A GUI wrapped around fig2vect may allow the user to create driver configurations and passes the configuration file contents as standard input to "fig2vect --write-configuration-file".

Parameters:
c Conversion job structure.
Returns:
1 on success, 0 on error.

static void establish_base_driver_name ( dk_fig_conversion c  )  [static]

Find base driver name.

Parameters:
c Conversion job structure.

static char* find_fig_suffix ( char *  n  )  [static]

Find suffix of input file to chech whether the file is plain text or compressed.

Parameters:
n File name.
Returns:
Pointer to suffix or NULL.

static int get_base_driver ( char *  n  )  [static]

Get base driver number.

Parameters:
n Driver name.
Returns:
The base driver number (or -1 on error).

static void initialize_options_storage ( dk_fig_conversion c,
int  what 
) [static]

Initialize options storage.

This function is invoked during the initialization of a conversion job structure.

Parameters:
c Conversion job structure.
what Index, which storage to initialize.

static size_t largest_of ( dk_storage_t *  sto,
dk_storage_iterator_t *  it 
) [static]

Find largest line size in a storage.

Parameters:
sto Storage.
it Storage iterator.
Returns:
Line size of the longest option.

static int lets_go_now ( dk_fig_conversion c  )  [static]

Check whether running on files or on a directory, run the conversion(s).

Parameters:
c Conversion job structure.
Returns:
1 on success, 0 on error.

static int run_for_directory ( dk_fig_conversion c  )  [static]

Run for a directory, convert all Fig files found.

Parameters:
c Conversion job structure.
Returns:
1 on success, 0 on error.

static int run_for_filenames ( dk_fig_conversion c  )  [static]

Run with filenames possibly containing wildcards.

Parameters:
c Conversion job structure.
Returns:
1 on success, 0 on error.

static int run_for_stdio ( dk_fig_conversion c  )  [static]

Run as filter (standard input, standard output).

Parameters:
c Conversion job structure.
Returns:
1 on success, 0 on error.

static int run_for_streams ( dk_fig_conversion c  )  [static]

Run for opened streams.

Both input and output stream are opened. Wildcards in file names are expanded, the real file names are in inf2 and ofn2.

Parameters:
c Conversion job structure.
Returns:
1 on success, 0 on error.

static int run_with_ifn2 ( dk_fig_conversion c  )  [static]

Run with input file name (wildcards are resolved).

Parameters:
c Conversion job structure.
Returns:
1 on success, 0 on error.

static int run_with_istream ( dk_fig_conversion c  )  [static]

Run with opened input stream.

Parameters:
c Conversion job structure.
Returns:
1 on success, 0 on error.

static int run_with_ofn2 ( dk_fig_conversion c  )  [static]

Open output stream and continue.

The output file name is fully known now.

Parameters:
c Conversion job structure.
Returns:
1 on success, 0 on error.

static void save_co_settings ( dk_fig_conversion cd,
dk_fig_conversion cs 
) [static]

Save conversion job settings.

Parameters:
cd Destination structure.
cs Source structure.

static void set_driver ( dk_fig_conversion c,
char *  drn,
int *  bck 
) [static]

Set driver name.

Parameters:
c Conversion job structure.
drn Driver name.
bck Pointer to variable for error code.

static void set_lcfge ( dk_fig_conversion c  )  [static]

Find largest line size for all option storages.

Parameters:
c Conversion job structure.

static int set_tex_filenames ( dk_fig_conversion c  )  [static]

Find names for temporary files.

Parameters:
c Conversion job structure.
Returns:
1 on success, 0 on error.


Variable Documentation

char* base_driver_names[] [static]

Initial value:

 {
        "mp",
        "mmp",
        "eps",
        "svg",
        "tex",
        "bb",
        "pdf",
        "ps",
        "java",
  NULL
}
Driver base names.

unsigned long builtin_default_options1 [static]

Initial value:

 
 0x00000200UL 
|  0x00000400UL 
|  0x00000800UL 
|  0x00020000UL 
|  0x00080000UL 
|  0x00100000UL 
|  0x01000000UL 
|  0x08000000UL 
|  0x20000000UL
Builtin default options (1).

unsigned long builtin_default_options2 [static]

Initial value:

 0x00000040UL 
|  0x00000080UL 
|  0x00001000UL 
|  0x00080000UL
Builtin default options(2).

char* figsuffixes[] [static]

Initial value:

 {
  ".fig", ".fig.gz", ".fig.bz2",
  NULL
}
Suffixes for XFig files we are willing to read.

int have_fncaseins [static]

Initial value:




0
Flag: Have case insensitive file names.

char* longopt_keywords[] [static]

Initial value:

 {
   "v$ersion",
   "h$elp",
   "c$onfigure",
   "u$nconfigure",
   "sh$ow-configuration",
   "m$ake",
   "o$ption",
   "l$anguage",
   "r$eset",
   "si$lently",
   "configuration-file",
   "write-configuration-file",
  NULL
}
Kkeywords for long options.

size_t max_line_length [static]

Initial value:




  (size_t)0
Maximum input line length.

char* output_suffixes[] [static]

Initial value:

 {
  ".mp",
  ".eps",
  ".svg",
  ".tex",
  ".bb",
  ".pdf",
  ".ps",
  ".java"
}
Suffixes for different output file types.

char* suffixes[] [static]

Initial value:

 {
  ".gz", ".bz2", ".svgz", NULL
}
Compression suffixes we can possibly handle.

size_t szkv = sizeof(kv)/sizeof(dk_key_value_t) [static]

Number of entries in the kv table.


Generated on Tue Nov 24 13:03:26 2009 for fig2vect by  doxygen 1.5.8