Refactor and reimplement dtudcfonted

This commit is contained in:
chase
2018-07-27 16:44:10 -05:00
committed by Jon Trulson
parent 0f1aaa3e46
commit b491f9134f
83 changed files with 3706 additions and 7498 deletions

View File

@@ -55,13 +55,22 @@
#include "bdfgpf.h"
static void ErrMsgTable_GetDefaultFile();
static int falcom_split_data() ;
static void dsp_font_list() ;
static int search_Font_File_Name();
static void ErrMsgTable_GetDefaultFile(char *com,
int ret,
int size,
char *style,
char *fname);
static int falcom_split_data(char *buf,
int entry_num,
char *elm[]);
static void dsp_font_list(FalFontDataList *flist);
static int search_Font_File_Name(FalFontData data, char *fname);
extern int searchFontFileName();
extern int falReadFontProp() ;
extern int searchFontFileName(FalFontData data, char *fullPathName);
extern int falReadFontProp(char *file,
int protect_key_data,
FalFontData *databuff,
int islock);
/*
* get "character size" and "letter size" from a character of an interface
@@ -76,10 +85,10 @@ extern int falReadFontProp() ;
#define BODY_AND_LETTER 2
static int
GetSize( size_str, body, letter )
char *size_str; /* a character of a size */
int *body; /* set "character size" (output) */
int *letter; /* set "letter size" (output) */
GetSize(
char *size_str, /* a character of a size */
int *body, /* set "character size" (output) */
int *letter) /* set "letter size" (output) */
{
char *str_dot;
/* char *str_end; */
@@ -120,18 +129,10 @@ int *letter; /* set "letter size" (output) */
*/
int
#if NeedFunctionPrototypes
falcom_atoi(
char *str, /* numerical character */
char ed_code,/* an end code in numerical character */
int *val /* set numarical data */
)
#else
falcom_atoi(str, ed_code, val)
char *str; /* numerical character */
char ed_code;/* an end code in numerical character */
int *val; /* set numarical data */
#endif
int *val) /* set numarical data */
{
char *ptr;
char *str_end;
@@ -153,8 +154,7 @@ int *val; /* set numarical data */
static int
falcom_cr_to_null(buf)
char *buf;
falcom_cr_to_null(char *buf)
{
buf = strchr( buf, '\n');
if (buf != NULL) {
@@ -173,18 +173,10 @@ char *buf;
int
#if NeedFunctionPrototypes
GetDefaultFile(
int size,
char *style,
char *fname
)
#else
GetDefaultFile( size, style, fname )
int size; /* character size */
char *style; /* character style */
char *fname; /* buffer */
#endif
int size, /* character size */
char *style, /* character style */
char *fname) /* buffer */
{
FILE *fp;
int ret;
@@ -213,20 +205,11 @@ char *fname; /* buffer */
int
#if NeedFunctionPrototypes
get_default_file(
FILE *fp,
int size,
char *style,
char *fname
)
#else
get_default_file( fp, size, style, fname )
FILE *fp;
int size; /* character size */
char *style; /* character style */
char *fname; /* buffer */
#endif
int size, /* character size */
char *style, /* character style */
char *fname) /* buffer */
{
char buf[BUFSIZE]; /* buffer */
int size_tmp; /* size (read file) */
@@ -273,10 +256,10 @@ char *fname; /* buffer */
/**************************************************************/
static int
falcom_split_data( buf, entry_num, elm )
char *buf; /* read a font information character array from a file */
int entry_num;
char *elm[];
falcom_split_data(
char *buf, /* read a font information character array from a file */
int entry_num,
char *elm[])
{
int cnt; /* counter */
int strtop_flg; /* flag of a head of a character array */
@@ -309,12 +292,7 @@ char *elm[];
char *
#if NeedFunctionPrototypes
falcom_get_base_name( char *str )
#else
falcom_get_base_name( str )
char *str; /* a full path character of a file name */
#endif
falcom_get_base_name( char *str /* a full path character of a file name */ )
{
char *str_slash;
@@ -327,8 +305,7 @@ char *str; /* a full path character of a file name */
static int
is_letter_size_not_only_one( lst )
FalFontDataList *lst; /* a font list */
is_letter_size_not_only_one( FalFontDataList *lst /* a font list */ )
{
int i, letter_cmp;
@@ -351,22 +328,12 @@ FalFontDataList *lst; /* a font list */
*
*/
int
#if NeedFunctionPrototypes
GetFileName(
char *com,
char *size_str,
char *style,
int codeset,
char *ofile
)
#else
GetFileName(com, size_str, style, codeset, ofile)
char *com; /* a character of a command name(case error) */
char *size_str; /* a character of "size" */
char *style; /* a character of "style" */
int codeset; /* a codeset */
char *ofile; /* set a target file name (output) */
#endif
char *com, /* a character of a command name(case error) */
char *size_str, /* a character of "size" */
char *style, /* a character of "style" */
int codeset, /* a codeset */
char *ofile) /* set a target file name (output) */
{
int body, letter;
int size_sw; /* a size flag */
@@ -570,18 +537,10 @@ char *fal_errmsg_org[0xff] = {
void
#if NeedFunctionPrototypes
ErrMsgTable_FalGetFontList(
char *com,
int utyerr,
int utyderr
)
#else
ErrMsgTable_FalGetFontList( com, utyerr, utyderr )
char *com; /* command name */
int utyerr; /* fal_utyerror */
int utyderr; /* fal_utyderror */
#endif
char *com, /* command name */
int utyerr, /* fal_utyerror */
int utyderr) /* fal_utyderror */
{
char *fontsdir, *locale ;
@@ -627,17 +586,15 @@ int utyderr; /* fal_utyderror */
}
}
/* take out an error message of "GetDefaultFile()" */
static void
ErrMsgTable_GetDefaultFile( com, ret, size, style, fname )
char *com; /* a command name */
int ret; /* return code */
int size; /* a character size */
char *style; /* a character style */
char *fname; /* user defined character information file name */
ErrMsgTable_GetDefaultFile(
char *com, /* a command name */
int ret, /* return code */
int size, /* a character size */
char *style, /* a character style */
char *fname) /* user defined character information file name */
{
switch (ret) {
case -1:
@@ -666,12 +623,7 @@ char *fname; /* user defined character information file name */
*/
void
#if NeedFunctionPrototypes
fal_cut_tailslash( char *name )
#else
fal_cut_tailslash( name )
char *name;
#endif
{
char *p;
@@ -695,12 +647,7 @@ char *name;
*/
char *
#if NeedFunctionPrototypes
GetRealFileName( char *name )
#else
GetRealFileName( name )
char *name;
#endif
{
static char *ret_name ;
char link_name[BUFSIZE];
@@ -760,18 +707,10 @@ char *name;
*/
int
#if NeedFunctionPrototypes
IsInRegion(
int code ,
int num_gr ,
FalGlyphRegion *gr
)
#else
IsInRegion(code, num_gr, gr)
int code ;
int num_gr ;
FalGlyphRegion *gr ;
#endif
FalGlyphRegion *gr)
{
int i ;
if( code < MIN_CODE || code > MAX_CODE ) return -1 ;
@@ -787,9 +726,7 @@ FalGlyphRegion *gr ;
static int
search_Font_File_Name( data, fname )
FalFontData data ;
char *fname ;
search_Font_File_Name( FalFontData data, char *fname )
{
FalFontID fid ;
FalFontDataList *flist ;
@@ -861,20 +798,11 @@ char *fname ;
int
#if NeedFunctionPrototypes
GetUdcFileName(
char *com ,
int code_no ,
char *xlfdname ,
char *fname
)
#else
GetUdcFileName( com, code_no, xlfdname, fname )
char *com ;
int code_no ;
char *xlfdname ;
char *fname ;
#endif
char *com,
int code_no,
char *xlfdname,
char *fname)
{
FalFontData data ;
@@ -891,8 +819,7 @@ char *fname ;
static void
dsp_font_list( flist )
FalFontDataList *flist ;
dsp_font_list( FalFontDataList *flist )
{
int i ;
@@ -910,22 +837,12 @@ FalFontDataList *flist ;
int
#if NeedFunctionPrototypes
GetUdcRegion(
char *com ,
int codeset ,
char *gpf_file ,
int *num_gr ,
FalGlyphRegion **gr
)
#else
GetUdcRegion( com, codeset, gpf_file, num_gr, gr )
char *com ;
int codeset ;
char *gpf_file ;
int *num_gr ;
FalGlyphRegion **gr ;
#endif
char *com,
int codeset,
char *gpf_file,
int *num_gr,
FalGlyphRegion **gr)
{
FalFontData fdata ;
char *locale, *char_set, *tmp_gpf ;
@@ -971,12 +888,7 @@ FalGlyphRegion **gr ;
#define MAX_CODESET 8
int
#if NeedFunctionPrototypes
DispUdcCpArea( FILE *fp )
#else
DispUdcCpArea( fp )
FILE *fp ;
#endif
{
int cd_set, j ;
FalFontDataList *fls ;
@@ -1026,18 +938,10 @@ FILE *fp ;
int
#if NeedFunctionPrototypes
GetUdcFontName(
char *gpf_file ,
char *bdf_file ,
char **fontname
)
#else
GetUdcFontName( gpf_file, bdf_file, fontname )
char *gpf_file ;
char *bdf_file ;
char **fontname ;
#endif
char **fontname)
{
FILE *fp ;
pid_t chld_pid = 0;

View File

@@ -48,12 +48,7 @@
*/
int
#if NeedFunctionPrototypes
FileLock( int fd )
#else
FileLock( fd )
int fd; /* a file descripter */
#endif
{
struct flock flpar;
@@ -83,12 +78,7 @@ int fd; /* a file descripter */
*/
int
#if NeedFunctionPrototypes
FileUnLock( int fd )
#else
FileUnLock( fd )
int fd; /* a file descripter */
#endif
{
struct flock flpar;
@@ -115,12 +105,7 @@ int fd; /* a file descripter */
*/
int
#if NeedFunctionPrototypes
isLock( int fd )
#else
isLock( fd )
int fd; /* file descripter */
#endif
{
struct flock flpar;

View File

@@ -52,7 +52,7 @@
#include "bdfgpf.h"
#include "udcutil.h"
static void exline();
static void exline(char *sp, char *dbuf, int sw, int dw);
char *oakgtobdf;
char *bdftosnf = BDFTOSNF;
@@ -66,16 +66,7 @@ static int put_file_create_err_msg = 0;
#define READ_FAIL 5
int
#if NeedFunctionPrototypes
ReadBdfHeader(
struct btophead *head,
char *buf
)
#else
ReadBdfHeader( head, buf )
struct btophead *head;
char *buf;
#endif
ReadBdfHeader(struct btophead *head, char *buf)
{
char *p;
unsigned int getstat = 0;
@@ -128,16 +119,7 @@ char *buf;
int
#if NeedFunctionPrototypes
ReadGpfHeader(
struct ptobhead *head,
char *buf
)
#else
ReadGpfHeader(head, buf)
struct ptobhead *head;
char *buf;
#endif
ReadGpfHeader(struct ptobhead *head, char *buf)
{
char *p;
unsigned int getstat = 0;
@@ -173,12 +155,7 @@ char *buf;
int
#if NeedFunctionPrototypes
WriteBdfHeader( struct ptobhead *head )
#else
WriteBdfHeader(head)
struct ptobhead *head;
#endif
{
FILE *fp;
int fd[2];
@@ -296,12 +273,7 @@ struct ptobhead *head;
void
#if NeedFunctionPrototypes
WriteGpfHeader( struct btophead *head )
#else
WriteGpfHeader(head)
struct btophead *head;
#endif
{
fprintf(head->output, "numfonts:%d\n", head->num_chars);
fprintf(head->output, "width:%d\n", head->p_width );
@@ -312,12 +284,7 @@ struct btophead *head;
int
#if NeedFunctionPrototypes
WritePtnToBdf( struct ptobhead *head )
#else
WritePtnToBdf(head)
struct ptobhead *head;
#endif
{
int msize, swidth, rtn, i, nchar;
char *zoomptn;
@@ -376,12 +343,7 @@ struct ptobhead *head;
int
#if NeedFunctionPrototypes
putDefaultChars( struct ptobhead *head )
#else
putDefaultChars(head )
struct ptobhead *head;
#endif
{
int swidth, bytew, i, j;
unsigned int posbit ;
@@ -408,12 +370,7 @@ struct ptobhead *head;
int
#if NeedFunctionPrototypes
WritePtnToGpf( struct btophead *head )
#else
WritePtnToGpf(head)
struct btophead *head;
#endif
{
int msize, rtn, i;
char *zoomptn;
@@ -456,16 +413,7 @@ struct btophead *head;
int
#if NeedFunctionPrototypes
ReadBdfToMemory(
struct btophead *head,
char *buf
)
#else
ReadBdfToMemory(head, buf)
struct btophead *head;
char *buf;
#endif
ReadBdfToMemory(struct btophead *head, char *buf)
{
int code, mwidth, num_char, bsize, rtn;
char *ptn;
@@ -502,20 +450,11 @@ char *buf;
int
#if NeedFunctionPrototypes
ReadBdfToMemory_with_init(
struct btophead *head,
int init_start,
int init_end,
char *buf
)
#else
ReadBdfToMemory_with_init(head, init_start, init_end, buf)
struct btophead *head;
int init_start;
int init_end;
char *buf;
#endif
int init_start,
int init_end,
char *buf)
{
int code, mwidth, num_char, bsize, rtn;
char *ptn;
@@ -555,18 +494,11 @@ char *buf;
int
#if NeedFunctionPrototypes
GetBdfCode(
struct btophead *head,
char *buf,
int *code
)
#else
GetBdfCode(head, buf, code)
struct btophead *head;
char *buf;
int *code;
#endif
{
char *p;
@@ -590,24 +522,13 @@ int *code;
return(0);
}
int
#if NeedFunctionPrototypes
GetBdfPtn(
struct btophead *head,
char *buf,
char *ptn,
int mwidth,
int bsize
)
#else
GetBdfPtn(head, buf, ptn, mwidth, bsize)
struct btophead *head;
char *buf;
char *ptn;
int mwidth;
int bsize;
#endif
int bsize)
{
int skip, i, j;
char *p;
@@ -654,16 +575,7 @@ int bsize;
int
#if NeedFunctionPrototypes
ReadGpfToMemory(
struct ptobhead *head,
char *buf
)
#else
ReadGpfToMemory(head, buf)
struct ptobhead *head;
char *buf;
#endif
ReadGpfToMemory(struct ptobhead *head, char *buf)
{
int code, mwidth, num_char, bsize, rtn;
char *ptn;
@@ -700,18 +612,7 @@ char *buf;
int
#if NeedFunctionPrototypes
GetGpfCode(
struct ptobhead *head,
char *buf,
int *code
)
#else
GetGpfCode(head, buf, code)
struct ptobhead *head;
char *buf;
int *code;
#endif
GetGpfCode(struct ptobhead *head, char *buf, int *code)
{
char *p;
@@ -735,9 +636,7 @@ int *code;
return(0);
}
int
#if NeedFunctionPrototypes
GetGpfPtn(
struct ptobhead *head,
char *buf,
@@ -745,14 +644,6 @@ GetGpfPtn(
int mwidth,
int bsize
)
#else
GetGpfPtn(head, buf, ptn, mwidth, bsize)
struct ptobhead *head;
char *buf;
char *ptn;
int mwidth;
int bsize;
#endif
{
int skip, i, j;
char *p;
@@ -788,18 +679,7 @@ int bsize;
void
#if NeedFunctionPrototypes
GetBdfLinePtn(
char *mem,
char *buf,
int width
)
#else
GetBdfLinePtn(mem, buf, width)
char *mem;
char *buf;
int width;
#endif
GetBdfLinePtn(char *mem, char *buf, int width)
{
int i, iend, len;
char *p, str[3];
@@ -831,18 +711,7 @@ int width;
}
void
#if NeedFunctionPrototypes
GetGpfLinePtn(
char *mem,
char *buf,
int width
)
#else
GetGpfLinePtn(mem, buf, width)
char *mem;
char *buf;
int width;
#endif
GetGpfLinePtn(char *mem, char *buf, int width)
{
unsigned int skip, i, iend, j;
unsigned char ptn;
@@ -876,20 +745,7 @@ int width;
int
#if NeedFunctionPrototypes
PutBdfPtn(
unsigned char *ptn,
int width,
int height,
FILE *fp
)
#else
PutBdfPtn(ptn, width, height, fp)
unsigned char *ptn;
int width;
int height;
FILE *fp;
#endif
PutBdfPtn(unsigned char *ptn, int width, int height, FILE *fp)
{
int i, j, nbyte ;
unsigned char *pbuf, x, c;
@@ -920,24 +776,8 @@ FILE *fp;
return(0);
}
int
#if NeedFunctionPrototypes
PutGpfPtn(
char *ptn,
int width,
int height,
FILE *fp
)
#else
PutGpfPtn(ptn, width, height, fp)
char *ptn;
int width;
int height;
FILE *fp;
#endif
PutGpfPtn(char *ptn, int width, int height, FILE *fp)
{
int i, j, k, nbyte, tw;
unsigned char p, *pbuf;
@@ -974,24 +814,7 @@ FILE *fp;
int
#if NeedFunctionPrototypes
PtnZoom(
char *dmem,
char *smem,
int sw,
int sh,
int dw,
int dh
)
#else
PtnZoom(dmem, smem, sw, sh, dw, dh)
char *dmem;
char *smem;
int sw;
int sh;
int dw;
int dh;
#endif
PtnZoom(char *dmem, char *smem, int sw, int sh, int dw, int dh)
{
int swidth;
int dwidth;
@@ -1031,11 +854,7 @@ int dh;
static void
exline(sp, dbuf, sw, dw)
char *sp;
char *dbuf;
int sw;
int dw;
exline(char *sp, char *dbuf, int sw, int dw)
{
unsigned int i, bit, sval, dval, dcnt, bcnt;
@@ -1065,12 +884,7 @@ int dw;
char *
#if NeedFunctionPrototypes
GetTmpPath( char *path )
#else
GetTmpPath( path )
char *path;
#endif
{
char *p=NULL, *sp, *buf ;
int len ;
@@ -1097,18 +911,12 @@ char *path;
if( *sp == '/' ) *sp-- = '\0' ;
sprintf( sp+1, "/%s", TEMPFILEKEY ) ;
/* Get temporary file name */
return mktemp( buf ) ;
return mkstemp( buf );
}
int
#if NeedFunctionPrototypes
Link_NewFile( char *rd_file, char *wr_file )
#else
Link_NewFile( rd_file, wr_file )
char *rd_file ;
char *wr_file ;
#endif
{
FILE *rfp, *wfp ;
int i, c ;
@@ -1187,12 +995,7 @@ char *wr_file ;
int
#if NeedFunctionPrototypes
ChkNumString( char *str )
#else
ChkNumString( str )
char *str;
#endif
ChkNumString( char *str )
{
char *tmp;
int num;
@@ -1209,7 +1012,6 @@ char *str;
void
#if NeedFunctionPrototypes
ErrMsgTable_AndExit(
int er_no,
char *snf_in,
@@ -1219,16 +1021,6 @@ ErrMsgTable_AndExit(
char *bdf_in,
char *prog_name
)
#else
ErrMsgTable_AndExit(er_no, snf_in, snf_out, gpf_in, gpf_out, bdf_in, prog_name)
int er_no;
char *snf_in;
char *snf_out;
char *gpf_in;
char *gpf_out;
char *bdf_in;
char *prog_name ;
#endif
{
int rtn = 0 ;
switch(er_no) {
@@ -1305,16 +1097,7 @@ char *prog_name ;
void
#if NeedFunctionPrototypes
fatal_err_msg(
int er_no,
char *prog_name
)
#else
fatal_err_msg( er_no, prog_name )
int er_no;
char *prog_name;
#endif
fatal_err_msg(int er_no, char *prog_name)
{
USAGE1("%s : The font file failed to be converted. ", prog_name);
switch( er_no ) {
@@ -1371,13 +1154,12 @@ static int sig_flg=0;
#define CATCH_SIGNAL 10
void
ChatchSig()
ChatchSig(void)
{
sig_flg = 1;
}
void
#if NeedFunctionPrototypes
Put_File_Create_Err_Msg(
int msg_level,
char *org_name,
@@ -1385,14 +1167,6 @@ Put_File_Create_Err_Msg(
char *save_name,
char *com
)
#else
Put_File_Create_Err_Msg( msg_level, org_name, tmp_name, save_name, com )
int msg_level;
char *org_name;
char *tmp_name;
char *save_name;
char *com;
#endif
{
switch( msg_level ) {
case GPF_BUCK_UP_FAIL:
@@ -1419,7 +1193,6 @@ char *com;
}
int
#if NeedFunctionPrototypes
Make_NewFefFile(
char *org_name,
char *tmp_name,
@@ -1428,15 +1201,6 @@ Make_NewFefFile(
gid_t group,
char *com
)
#else
Make_NewFefFile( org_name, tmp_name, mode, owner, group, com )
char *org_name;
char *tmp_name;
mode_t mode;
uid_t owner;
gid_t group;
char *com;
#endif
{
struct stat statbuf;
char *save_name = NULL;
@@ -1503,16 +1267,7 @@ char *com;
int
#if NeedFunctionPrototypes
Unlink_Tmpfile(
char *file,
char *com
)
#else
Unlink_Tmpfile( file, com )
char *file;
char *com;
#endif
Unlink_Tmpfile(char *file,char *com)
{
errno = 0;
if ( unlink( file ) != 0 ) {
@@ -1524,18 +1279,7 @@ char *com;
int
#if NeedFunctionPrototypes
Chmod_File (
char *fname,
mode_t mode,
char *com
)
#else
Chmod_File ( fname, mode, com )
char *fname;
mode_t mode;
char *com;
#endif
Chmod_File (char *fname, mode_t mode, char *com)
{
errno = 0;
if ( mode == 0 ) return( 0 ) ;
@@ -1548,20 +1292,7 @@ char *com;
int
#if NeedFunctionPrototypes
Chown_File (
char *fname,
uid_t owner,
gid_t group,
char *com
)
#else
Chown_File ( fname, owner, group, com )
char *fname;
uid_t owner;
gid_t group;
char *com;
#endif
Chown_File (char *fname, uid_t owner, gid_t group, char *com)
{
errno = 0;
if ( chown (fname, owner, group) != 0) {
@@ -1577,12 +1308,7 @@ char *com;
int
#if NeedFunctionPrototypes
ChkPcfFontFile( char *filename )
#else
ChkPcfFontFile( filename )
char *filename;
#endif
ChkPcfFontFile( char *filename )
{
char *suffix;
@@ -1599,12 +1325,7 @@ char *filename;
int
#if NeedFunctionPrototypes
ChkSnfFontFile( char *filename )
#else
ChkSnfFontFile( filename )
char *filename;
#endif
ChkSnfFontFile( char *filename )
{
char *suffix;
@@ -1621,16 +1342,7 @@ char *filename;
char *
#if NeedFunctionPrototypes
get_cmd_path(
char *path,
char *cmd
)
#else
get_cmd_path( path, cmd )
char *path;
char *cmd;
#endif
get_cmd_path(char *path, char *cmd)
{
char *cmd_path = NULL;
struct stat st;
@@ -1673,20 +1385,7 @@ char *cmd;
}
int
#if NeedFunctionPrototypes
SetCmdPath(
char *com ,
char **path ,
char *dflt_path ,
char *cmd
)
#else
SetCmdPath( com, path, dflt_path, cmd )
char *com ;
char **path ;
char *dflt_path ;
char *cmd ;
#endif
SetCmdPath(char *com, char **path, char *dflt_path, char *cmd)
{
struct stat statbuf ;
char *pbuf ;