Back to index

tetex-bin  3.0
Defines | Functions | Variables
omfonts.c File Reference
#include "cpascal.h"
#include "parser.h"
#include "manifests.h"
#include "omfonts.h"
#include "list_routines.h"
#include "error_routines.h"
#include "header_routines.h"
#include "font_routines.h"
#include "param_routines.h"
#include "char_routines.h"
#include "dimen_routines.h"
#include "parse_ofm.h"

Go to the source code of this file.

Defines

#define OFM2OPL
#define OPL2OFM
#define OVP2OVF
#define OVF2OVP
#define PROG_MIN   0
#define PROG_OFM2OPL   0
#define PROG_OVF2OVP   1
#define PROG_OPL2OFM   2
#define PROG_OVP2OVF   3
#define PROG_MAX   3
#define cmdline(i)   (argv[i])
#define BIG_BLOCK   0x20000
#define LITTLE_BLOCK   0x1000

Functions

int main (int argc, string *argv)
void read_in_whole (unsigned char **contents_loc, unsigned *length_loc, FILE *file, string name)
void init_tables (void)
void output_text_file (FILE *dest)

Variables

FILEyyin
int verbose_option
int char_format = CHAR_CODE_NUM
int num_format = NUM_CODE_HEX
int text_format = TEXT_CODE_MIXED
int program
string name_ofm = NULL
string name_opl = NULL
string name_ovp = NULL
string name_ovf = NULL
FILEfile_ofm = NULL
FILEfile_opl = NULL
FILEfile_ovp = NULL
FILEfile_ovf = NULL
FILEfile_output = NULL
unsigned char * ofm = NULL
unsigned char * ovf = NULL
unsigned length_ofm = 0
unsigned length_ovf = 0
const_string name_program
const_stringname_help
string name_msg
string name_empty = NULL
int no_files = 0
stringfiles [3] = {NULL, NULL, NULL}
string suffixes [3] = {NULL, NULL, NULL}
string full_suffixes [3] = {NULL, NULL, NULL}
static struct option []

Define Documentation

#define BIG_BLOCK   0x20000

Definition at line 273 of file omfonts.c.

#define cmdline (   i)    (argv[i])

Definition at line 50 of file omfonts.c.

#define LITTLE_BLOCK   0x1000

Definition at line 274 of file omfonts.c.

#define OFM2OPL

Definition at line 24 of file omfonts.c.

#define OPL2OFM

Definition at line 25 of file omfonts.c.

#define OVF2OVP

Definition at line 27 of file omfonts.c.

#define OVP2OVF

Definition at line 26 of file omfonts.c.

#define PROG_MAX   3

Definition at line 46 of file omfonts.c.

#define PROG_MIN   0

Definition at line 41 of file omfonts.c.

#define PROG_OFM2OPL   0

Definition at line 42 of file omfonts.c.

#define PROG_OPL2OFM   2

Definition at line 44 of file omfonts.c.

#define PROG_OVF2OVP   1

Definition at line 43 of file omfonts.c.

#define PROG_OVP2OVF   3

Definition at line 45 of file omfonts.c.


Function Documentation

Definition at line 311 of file omfonts.c.

{
    font_table_init(); /* subsidiary fonts in virtual fonts */
    init_header();
    init_planes();
    init_measures();
}

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
string argv 
)

Definition at line 98 of file omfonts.c.

{
    int getopt_return_val;
    int option_index = 0;

    name_program = xbasename(argv[0]);
    if (!strcmp(name_program, "ofm2opl") ||
        !strcmp(name_program, "OFM2OPL.EXE")) {
        program = PROG_OFM2OPL;
        name_help = OFM2OPLHELP;
       name_program = "ofm2opl";
        name_msg = "This is ofm2opl, Version 2.0";
        no_files = 2;
        files[0] = &name_ofm;
        files[1] = &name_opl;
        suffixes[0] = "ofm";
        suffixes[1] = "opl";
        full_suffixes[0] = ".ofm";
        full_suffixes[1] = ".opl";
    } else if (!strcmp(name_program, "opl2ofm") ||
               !strcmp(name_program, "OPL2OFM.EXE")) {
        program = PROG_OPL2OFM;
        name_help = OPL2OFMHELP;
       name_program = "opl2ofm";
        name_msg = "This is opl2ofm, Version 2.0";
        no_files = 2;
        files[0] = &name_opl;
        files[1] = &name_ofm;
        suffixes[0] = "opl";
        suffixes[1] = "ofm";
        full_suffixes[0] = ".opl";
        full_suffixes[1] = ".ofm";
    } else if (!strcmp(name_program, "ovp2ovf") ||
               !strcmp(name_program, "OVP2OVF.EXE")) {
        program = PROG_OVP2OVF;
        name_help = OVP2OVFHELP;
       name_program = "ovp2ovf";
        name_msg = "This is ovp2ovf, Version 2.0";
        no_files = 3;
        files[0] = &name_ovp;
        files[1] = &name_ovf;
        files[2] = &name_ofm;
        suffixes[0] = "ovp";
        suffixes[1] = "ovf";
        suffixes[2] = "ofm";
        full_suffixes[0] = ".ovp";
        full_suffixes[1] = ".ovf";
        full_suffixes[2] = ".ofm";
    } else if (!strcmp(name_program, "ovf2ovp") ||
               !strcmp(name_program, "OVF2OVP.EXE")) {
        program = PROG_OVF2OVP;
        name_help = OVF2OVPHELP;
       name_program = "ovf2ovp";
        name_msg = "This is ovf2ovp, Version 2.0";
        no_files = 3;
        files[0] = &name_ovf;
        files[1] = &name_ofm;
        files[2] = &name_ovp;
        suffixes[0] = "ovf";
        suffixes[1] = "ofm";
        suffixes[2] = "ovp";
        full_suffixes[0] = ".ovf";
        full_suffixes[1] = ".ofm";
        full_suffixes[2] = ".ovp";
    } else {
        fprintf(stderr , "Unrecognized program: %s\n", name_program);
        fprintf(stderr ,
        "This binary supports ofm2opl, opl2ofm, ovf2ovp, and ovp2ovf\n");
        exit(1);
    }
    kpse_set_program_name(name_program, NULL);
    kpse_init_prog(uppercasify(name_program), 0, nil, nil);

    do {
        getopt_return_val =
        getopt_long_only(argc, argv, "", long_options, &option_index) ;
        if (getopt_return_val == -1) { ; }
        else if ( getopt_return_val == 63 ) {
            usage (name_program);
        } else if (!strcmp(long_options[option_index].name, "help")) {
            usagehelp (name_help, NULL);
        } else if (!strcmp(long_options[option_index ].name, "version")) {
            printversionandexit(name_msg, nil,
                "J. Plaice, Y. Haralambous, D.E. Knuth");
        } else if (!strcmp(long_options[option_index ].name, "char-format")) {
            if (!strcmp(optarg, "ascii")) char_format = CHAR_CODE_ASCII;
            else if (!strcmp(optarg, "num")) char_format = CHAR_CODE_NUM;
            else warning_s("Bad character code format (%s)", optarg);
        } else if (!strcmp(long_options[option_index ].name, "num-format")) {
            if (!strcmp(optarg, "hex")) num_format = NUM_CODE_HEX;
            else if (!strcmp(optarg, "octal")) num_format = NUM_CODE_OCTAL;
            else warning_s("Bad number code format (%s)", optarg);
        } else if (!strcmp(long_options[option_index ].name, "text-format")) {
            if (!strcmp(optarg, "upper")) text_format = TEXT_CODE_UPPER;
            else if (!strcmp(optarg, "mixed")) text_format = TEXT_CODE_MIXED;
            else warning_s("Bad text code format (%s)", optarg);
        }
    } while (getopt_return_val != -1);
    if (((argc-optind) > no_files) || ((argc-optind) < 1)) {
        fprintf(stderr , "%s: %s\n", name_program,
                no_files == 2 ? "Need one or two file arguments."
                              : "Need one to three file arguments.");
        usage (name_program);
    }
    *(files[0]) = extend_filename(cmdline(optind) , suffixes[0]);
    if (optind+2 <= argc) {
        *(files[1]) = extend_filename(cmdline(optind+1) , suffixes[1]);
        if (no_files == 3) {
            if (optind+3 <= argc) {
                *(files[2]) = extend_filename(cmdline(optind+2) , suffixes[2]);
            } else if (program == PROG_OVP2OVF) {
                *(files[2]) = extend_filename(cmdline(optind+1), suffixes[2]);
            }
        }
    } else if (program != PROG_OFM2OPL) {
        *(files[1]) = basenamechangesuffix(*(files[0]),
                      full_suffixes[0], full_suffixes[1]);
        if ((no_files == 3) && (program == PROG_OVP2OVF)) {
            *(files[2]) = basenamechangesuffix(*(files[0]),
                      full_suffixes[0], full_suffixes[2]);
        }
    }

    switch(program) {
        case PROG_OFM2OPL: {
            file_ofm = kpse_open_file(name_ofm, kpse_ofm_format);
            read_in_whole(&ofm, &length_ofm, file_ofm, name_ofm);
            (void)fclose(file_ofm);
            if (name_opl==NULL) file_opl = stdout;
            else rewrite(file_opl, name_opl);
            file_output = file_opl;
            parse_ofm(FALSE);
            break;
        }
        case PROG_OVF2OVP: {
            file_ovf = kpse_open_file(name_ovf, kpse_ovf_format);
            read_in_whole(&ovf, &length_ovf, file_ovf, name_ovf);
            (void)fclose(file_ovf);
            file_ofm = kpse_open_file(name_ofm, kpse_ofm_format);
            read_in_whole(&ofm, &length_ofm, file_ofm, name_ofm);
            (void)fclose(file_ofm);
            if (name_ovp==NULL) file_ovp = stdout;
            else rewrite(file_ovp, name_ovp);
            file_output = file_ovp;
            parse_ofm(TRUE);
            break;
        }
        case PROG_OPL2OFM: {
            file_opl = kpse_open_file(name_opl, kpse_opl_format);
            rewritebin(file_ofm, name_ofm);
            init_tables();
            yyin = file_opl;
            (void)yyparse();
            output_ofm_file();
            (void)fclose(file_ofm);
            break;
        }
        case PROG_OVP2OVF: {
            file_ovp = kpse_open_file(name_ovp, kpse_ovp_format);
            rewritebin(file_ovf, name_ovf);
            rewritebin(file_ofm, name_ofm);
            init_tables();
            yyin = file_ovp;
            (void)yyparse();
            output_ofm_file();
            /*(void)fclose(file_ofm);*/
            output_ovf_file();
            (void)fclose(file_ovf);
            break;
        }
        default: {exit(1);}
    }
    exit(0);
}

Here is the call graph for this function:

void output_text_file ( FILE dest)

Definition at line 320 of file omfonts.c.

{
}
void read_in_whole ( unsigned char **  contents_loc,
unsigned *  length_loc,
FILE file,
string  name 
)

Definition at line 277 of file omfonts.c.

{
    unsigned no_read;
    unsigned no_total_read = 0;
    unsigned size = BIG_BLOCK;
    string where;
    string current_block;

    current_block = (char *) xmalloc(size);
    where = current_block;

    while (1) {
        no_read = fread(where, 1, LITTLE_BLOCK, file);
        no_total_read += no_read;
        if ((no_total_read+LITTLE_BLOCK) > size) {
            size *= 2;
            current_block = (char *) xrealloc(current_block, size);
        }
        where = current_block + no_total_read;
        if (ferror(file)) {
            fatal_error_s("Error while reading file %s", name);
        } else if (feof(file)) {
            break;
        }
    }

    *contents_loc = (unsigned char *) current_block;
    *length_loc = no_total_read;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 53 of file omfonts.c.

Definition at line 64 of file omfonts.c.

Definition at line 65 of file omfonts.c.

Definition at line 68 of file omfonts.c.

Definition at line 67 of file omfonts.c.

Definition at line 66 of file omfonts.c.

string* files[3] = {NULL, NULL, NULL}

Definition at line 83 of file omfonts.c.

Definition at line 85 of file omfonts.c.

unsigned length_ofm = 0

Definition at line 73 of file omfonts.c.

unsigned length_ovf = 0

Definition at line 74 of file omfonts.c.

Definition at line 80 of file omfonts.c.

Definition at line 77 of file omfonts.c.

Definition at line 78 of file omfonts.c.

Definition at line 59 of file omfonts.c.

Definition at line 60 of file omfonts.c.

Definition at line 62 of file omfonts.c.

Definition at line 61 of file omfonts.c.

Definition at line 76 of file omfonts.c.

Definition at line 82 of file omfonts.c.

Definition at line 54 of file omfonts.c.

unsigned char* ofm = NULL

Definition at line 70 of file omfonts.c.

struct option[] [static]
Initial value:
 {
    {"verbose", 0, &verbose_option, 1},
    {"char-format", 1, 0, 0},
    {"num-format", 1, 0, 0},
    {"text-format", 1, 0, 0},
    {"help", 0, 0, 0},
    {"version", 0, 0, 0},
    {0, 0, 0, 0}
}

Definition at line 87 of file omfonts.c.

unsigned char* ovf = NULL

Definition at line 71 of file omfonts.c.

Definition at line 57 of file omfonts.c.

Definition at line 84 of file omfonts.c.

Definition at line 55 of file omfonts.c.

Definition at line 52 of file omfonts.c.