From 7cce5580ddbc269988e5111cdea24b6ec30151a5 Mon Sep 17 00:00:00 2001 From: Johns Date: Mon, 26 Jan 2009 12:39:04 +0100 Subject: [PATCH] Start parsing bdf files. --- bdf2c.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/bdf2c.c b/bdf2c.c index b0b02f4..3de1799 100644 --- a/bdf2c.c +++ b/bdf2c.c @@ -49,6 +49,27 @@ void CreateFontHeaderFile(FILE * out) ////////////////////////////////////////////////////////////////////////////// +// +// Read BDF font file. +// +void ReadBdf(FILE* bdf) +{ + char linebuf[1024]; + char *s; + + for (;;) { + if ( !fgets(linebuf, sizeof(linebuf), bdf) ) { // EOF + break; + } + if ( !(s = strtok(linebuf, " \t\n\r")) ) { // empty line + break; + } + printf("token:%s\n", s); + } +} + +////////////////////////////////////////////////////////////////////////////// + // // Print version // @@ -64,7 +85,10 @@ void PrintVersion(void) // void PrintUsage(void) { - printf("Usage: bdf2c [OPTIONs]\n"); + printf("Usage: bdf2c [OPTIONs]\n" + "\t-c\tCreate font header on stdout\n" + "\t-C file\tCreate font header file\n" + ); printf("\tOnly idiots print usage on stderr\n"); } @@ -77,7 +101,10 @@ int main(int argc, char *const argv[]) // Parse arguments. // for (;;) { - switch (getopt(argc, argv, "cC:h?-")) { + switch (getopt(argc, argv, "bcC:h?-")) { + case 'b': + ReadBdf(stdin); + break; case 'c': CreateFontHeaderFile(stdout); break;