/*****  名前ジェネレータ namegen    *****/
/*****  error.c                     *****/



#include <stdio.h>
#include <stdlib.h>
#include "namegen.h"
#include "put.h"


void error(int  errnum,             /*  エラー番号                          */
           char *errline            /*  エラー行文字列へのポインタ          */
           ){

    if (errline != NULL){           /*  エラー行を出力                      */
        putstr("Line  :", stderr);
        putstr(errline, stderr);
    }
    switch (errnum){
        case ERR_HELP :
            help();
            break;
        case ERR_NAMEFILE_NOT_FOUND :
            putstr("Error : Cannot open namefile.\n", stderr);
            break;
        case ERR_OUT_OF_MEMORY :
            putstr("Error : Out of memory.\n", stderr);
            break;
        case ERR_ILLEGAL_FIELDMAX :
            putstr("Error : Illegal number of fields.\n", stderr);
            break;
        case ERR_ILLEGAL_PROB :
            putstr("Error : Value of probability is out of range.\n", stderr);
            break;
        case ERR_UNDEF_PROB :
            putstr("Error : Field generation probability is undefined.\n",
                   stderr);
            break;
        case ERR_ILLEGAL_CTRL :
            putstr("Error : Illegal control command.\n", stderr);
            break;
        case ERR_ILLEGAL_FIELDNUM :
            putstr("Error : Field number is out of range.\n", stderr);
            break;
        case ERR_UNDEF_WORD :
            putstr("Error : No word is defined in the generatable field.\n",
                   stderr);
            break;
        case ERR_ILLEGAL_NEST :
            putstr("Error : Nesting of file is too deep.\n", stderr);
            break;
        case ERR_ILLEGAL_INSERT :
            putstr("Error : Filename is missing in insertion.\n", stderr);
            break;
    }
    exit(errnum);
}

