/*
 * This file belongs to FreeMiNT. It's not in the original MiNT 1.12
 * distribution. See the file CHANGES for a detailed log of changes.
 * 
 * 
 * Copyright 2000-2004 Frank Naumann <fnaumann@freemint.de>
 * All rights reserved.
 * 
 * Please send suggestions, patches or bug reports to me or
 * the MiNT mailing list.
 * 
 * 
 * This file is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 * 
 * This file 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 for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see
 * <http://www.gnu.org/licenses/>.
 */

#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>

#include "syscalldefs.h"
#include "syscallparser.h"


void
print_head(FILE *out, const char *myname)
{
	fprintf(out, "/*\n * %s *\n", myname);
	fprintf(out,
		" * DO NOT EDIT - this file is automatically generated!\n"
		" */\n"
	);
	fprintf(out, "\n");
	
	fprintf(out,
		"/*\n"
		" * This file belongs to FreeMiNT. It's not in the original MiNT 1.12\n"
		" * distribution. See the file CHANGES for a detailed log of changes.\n"
		" *\n"
		" *\n"
		" * Copyright 2000-2005 Frank Naumann <fnaumann@freemint.de>\n"
		" * All rights reserved.\n"
		" *\n"
		" * Please send suggestions, patches or bug reports to me or\n"
		" * the MiNT mailing list.\n"
		" *\n"
		" *\n"
		" * This file is free software; you can redistribute it and/or modify\n"
		" * it under the terms of the GNU General Public License as published by\n"
		" * the Free Software Foundation; either version 2, or (at your option)n"
		" * any later version.\n"
		" *\n"
		" * This file is distributed in the hope that it will be useful,\n"
		" * but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
		" * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
		" * GNU General Public License for more details.\n"
		" *\n"
		" * You should have received a copy of the GNU General Public License\n"
		" * along with this program; if not, see\n"
		" * <http://www.gnu.org/licenses/>.\n"
		" *\n"
		" */\n"
	);
	fprintf(out, "\n");
}

int is_syscall(struct syscall *call)
{
	int ret = 0;

	switch (call->status)
	{
	case SYSCALL_REGULAR:
	case SYSCALL_UNIMPLEMENTED:
	case SYSCALL_UNSUPPORTED:
	case SYSCALL_NOCLOBBER:
		ret = 1;
		break;
	case SYSCALL_PASSTHROUGH:
		ret = strcmp(call->name, "passthrough") != 0;
		break;
	case SYSCALL_UNDEFINED:
		break;
	default:
		assert(0);
		break;
	}

	return ret;
}

/* from parser */
int yyparse(void);
extern FILE *yyin, *yyout;

int errors = 0;

int
parse_syscall_description(FILE *infile)
{
	yyin = infile;

	yyparse();

	return errors;
}
