home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 12 Font
/
12-Font.zip
/
PFMAFM.ZIP
/
PFB2PFA.C
< prev
next >
Wrap
Text File
|
1991-09-22
|
2KB
|
90 lines
/*****************************************************************************/
/* */
/* P F B 2 P F A */
/* */
/*****************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define TXT_BLOCK 0x180
#define BIN_BLOCK 0x280
#define EOF_BLOCK 0x380
unsigned long getl (FILE *);
void do_block (FILE *, FILE *);
void main (int argc, char *argv[])
{
FILE *fp;
FILE *ofp;
if (argc != 2)
{
printf ("Error dude\n");
exit (EXIT_FAILURE);
}
if (NULL == (fp = fopen (argv[1], "rb")))
{
perror (argv[1]);
exit (EXIT_FAILURE);
}
ofp = stdout;
while (!feof (fp))
do_block (ofp, fp);
fclose (fp);
exit (EXIT_SUCCESS);
}
void do_block (FILE *ofp, FILE *ifp)
{
int block_type;
unsigned long blk_len;
int ch;
block_type = getw (ifp);
switch (block_type)
{
case TXT_BLOCK:
blk_len = getl (ifp);
while (blk_len-- > 0)
fputc (fgetc (ifp), ofp);
break;
case BIN_BLOCK:
blk_len = getl (ifp);
while (blk_len-- > 0)
{
ch = fgetc (ifp);
fprintf (ofp, "%02x", ch);
if (blk_len % 40 == 0)
fprintf (ofp, "\n");
}
fprintf (ofp, "\n");
break;
case EOF_BLOCK:
while (! feof (ifp))
fgetc (ifp);
break;
default:
fprintf (stderr, "Unknown block type 0x%04x\n", block_type);
exit (EXIT_FAILURE);
}
}
unsigned long getl (FILE *fp)
{
unsigned long ul;
fread (&ul, 1, 4, fp);
return (ul);
}