/*************************************************************************** * Copyright (C) 2006 by m3nt4L * * m3nt4L@in.gr * * * * This program 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 of the License, or * * (at your option) any later version. * * * * 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 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., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include "colours.h" /*definition of colours and names */ #define LINE_LENGTH 80 #define SHIPNAME_LENGTH 20 int paramcheck(int,char*[],FILE*,FILE*); /*Checking if the parameters are corect */ int crread(cr*,FILE*); /*Reading the combat report from input file */ int main(int argc, char *argv[]) { FILE *ifile,*ofile; /*input & output file */ cr *crbuffer = (cr*)malloc(sizeof(cr)); /*temporar Combat Report */ if (paramcheck(argc,argv,ifile,ofile)) /*wrong parameters */ return EXIT_FAILURE; /*exiting */ if (crread(crbuffer,ifile)) /*reading the report */ return EXIT_FAILURE; /*on error exit */ fclose(ifile); fclose(ofile); return EXIT_SUCCESS; } int paramcheck(int argc, char *argv[],FILE *ifile,FILE *ofile) { /*argc Check */ if (argc > 3){ printf("Critical Error: Too many arguments\n"); return 1; } if (argc < 3){ printf("Critical Error: Not enough arguments\n"); return 1; } /*File Validation */ if (ifile = fopen(argv[1],"r")){ printf("Critical Error: Could Not open Input file. Exiting\n"); return 1; } if (ofile = fopen(argv[2],"w")){ printf("Critical Error: Could Not open Output file. Exiting\n"); return 1; } /*Exiting Without errors */ return 0; } int crread(cr* crbuffer,FILE* ifile) { char names[21][SHIPNAME_LENGTH]; /*Contains the names of ships/defences, Fleet 1st, */ char line[LINE_LENGTH]; /*line input */ wnames(names); /*filling the table */ //TODO: SCAN THE REPORT AND FILL THE CRBUFFER /* fseek to Seek inthe file (in Bytes) "use sizeof" ftell to Get current position (offset) */ return 0; }