Hogwarts Wand Docs: ../sw/wand_convert.c

Wand Sourcecode: ../sw/wand_convert.c

//
// wand_convert.c - OBSOLETE
//
// Copyright (C) 2006  Nathan (Acorn) Pooley
// 
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// version 2 as published by the Free Software Foundation.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License (gpl.txt) for more details. 
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
// 
// You can contact the author, Nathan (Acorn) Pooley, by writing
// to Nathan (Acorn) Pooley, 949 Buckeye Drive, Sunnyvale, CA  94086, USA
// or through the form at http://www.rawbw.com/~acorn/wand/feedback.html
//
//#@DOC@ NEVER FINISHED - program to process wand data - NOT USED

//###########################################################################
//############################### INCLUDES ##################################
//###########################################################################

#include <stdio.h>

//###########################################################################
//############################### DEFINES ###################################
//###########################################################################

#define STRING_FILENAME     "wand_strings.txt"
#define CHAR_FILENAME       "wand_chars.txt"
#define OUT_FILENAME        "wand_data.inc"

//###########################################################################
//############################### TYPEDEFS ##################################
//###########################################################################

typedef struct WandDataRec {
    
} WandData;

//###########################################################################
//############################### GLOBALS ###################################
//###########################################################################

//###########################################################################
//############################### CODE ######################################
//###########################################################################

//===========================================================================
// ParseError()
//===========================================================================
void ParseError(WandData *wand)
{
    fprintf(stderr,"Parse error at %s:%d\n",
        wand->in_filename?wand->in_filename:"<no-file>
}

//===========================================================================
// Getline()
//===========================================================================
char *Getline(WandData *wand)
{
    static char buf[1000];
    char *s = buf;
    while(1) {
        int c = getc(wand->in);
        if (c == EOF || c=='\n') {
            if (s == buf) {
                return 0;
            }
            *s = 0;
            return strdup(buf);
        }
        if (s - buf > sizeof(buf)-2) {
            fprintf(stderr,"Line too long\n");
            ParseError(wand);
        }
    }
}

//===========================================================================
// ParseChars()
//===========================================================================
void ParseChars(WandData *wand, FILE *in)
{

}

//===========================================================================
// ParseStrings()
//===========================================================================
void ParseStrings(WandData *wand, FILE *in)
{

}

//===========================================================================
// Output()
//===========================================================================
void Output(WandData *wand)
{

}

//===========================================================================
// InfileClose()
//===========================================================================
void InfileClose(WandData *wand)
{
    if (wand->in) {
        fclose(wand->in);
        wand->in = 0;
    }
    if (wand->in_filename) {
        free(wand->infilename);
        wand->in_filename = 0;
    }
    wand->in_line = -1;
}

//===========================================================================
// InfileOpen()
//===========================================================================
void InfileOpen(WandData *wand, const char *filename)
{
    InfileClose(wand);
    wand->in = fopen(filename,"r");
    if (!wand->in) {
        fprintf(stderr,"Error: could not open file '%s' for reading.\n",
            filename);
        exit(1);
    }
    wand->in_filename = strdup(filename);
    wand->in_line     = 1;
}


//===========================================================================
// main()
//===========================================================================
int main(int argc, char *argv[])
{
    FILE *fp;
    WandData wand[1];
    wand->string_filename = STRING_FILENAME;
    wand->char_filename   = CHAR_FILENAME;
    wand->out_filename    = OUT_FILENAME;

    wand->out = fopen(wand->out_filename,"w");
    if (!wand->out) {
        fprintf(stderr,"Error: could not open output file '%s' for writing.\n",
            wand->out_filename);
        exit(1);
    }

    InfileOpen(wand, wand->char_filename);
    ParseChars(wand);
    InfileClose(wand);

    InfileOpen(wand, wand->string_filename);
    ParseStrings(wand);
    InfileClose(wand);
    
    Output(wand);

    fclose(wand->out);

    return 0;
}

This file Copyright (C) 2006 by Nathan (Acorn) Pooley
Go to TOP Wand page
Go to Acorn's personal webpage
Go to Hogwarts website: www.gotohogwarts.com
Snout: www.snout.org/game
Gadgets of Justice Unlimited
Snout GC (Wiki)
Snout Wiki
File created by do_doc at Wed May 30 03:23:41 PDT 2007