gameIOManager.h File Reference

File containing the interface of gameIOManager module. More...

#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <assert.h>
#include <math.h>
#include <time.h>
#include <stdbool.h>
#include "define.h"
#include "schemaGameUtility.h"

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  gameRecordValues
 Data struct containing the game's records. More...

Functions

char ** readfile (char namefile[], bool *schema_ok, unsigned int *mapCurrentRow, unsigned int *mapCurrentCol, unsigned int mapMaxRow, unsigned int mapMaxCol, bool differentColLen)
 This function manages dinamic data loading processing from the configuration file.
char ** allocResetVariable (unsigned int mapMaxRow, unsigned int mapMaxCol)
 Allocs and reset the variable that will contains file content.
void skipCharacters (char *fileChar, int *checkchar, FILE *file2read)
 Skips all the EOF, ENDLINE and COMMENT characters.
bool readCharacters (unsigned int *mapCurrentCol, unsigned int mapMaxCol, const unsigned int *mapCurrentRow, unsigned int mapMaxRow, char **contentFile, FILE *file2read)
 If there aren't structural form error in file and while the file not end, reads all the characters and puts it into variable contentFile.
bool checkDifferentColLen (const unsigned int *mapCurrentRow, const unsigned int *mapCurrentCol, unsigned int *checkCol)
 Check if all the rows in the file has the same number of columns.
bool setGameRecordStructValue (char **filecontent, unsigned int numrow, unsigned int numcol)
 Save the game record list into the record data structure, checking characters using function isallowedchar.
bool readSetGameRecord (unsigned int *readrows)
 Read from record file the record list and save it in the record data struct, invoking the functions readfile and setGameRecordStructValue.
void save_record (const char *name, unsigned int totalpoints, unsigned int currentlevel)
 Save the new record in file, invoking the function readSetGameRecord.
void printschema ()
 Simple function that print on standard output the content of a matrix with the dimensions row x column in textual format (char).

Variables

struct gameRecordValues gameRecord [MAX_RECORD_SHOW]
 Data struct containing the game's records.


Detailed Description

File containing the interface of gameIOManager module.

Definition in file gameIOManager.h.


Function Documentation

char** allocResetVariable ( unsigned int  mapMaxRow,
unsigned int  mapMaxCol 
)

Allocs and reset the variable that will contains file content.

Returns:
double char pointer to the new variable.
Parameters:
mapMaxRow max row length
mapMaxCol max column length

Definition at line 98 of file gameIOManager.c.

References D1, and NULLCHAR.

Referenced by readfile().

Here is the caller graph for this function:

bool checkDifferentColLen ( const unsigned int *  mapCurrentRow,
const unsigned int *  mapCurrentCol,
unsigned int *  checkCol 
)

Check if all the rows in the file has the same number of columns.

Parameters:
mapCurrentRow row position
mapCurrentCol column position
checkCol Reference number of columns

Definition at line 189 of file gameIOManager.c.

References D1.

Referenced by readfile().

Here is the caller graph for this function:

void printschema (  ) 

Simple function that print on standard output the content of a matrix with the dimensions row x column in textual format (char).

It works only in debug modality. Warning: this function doesn't implement any sort of control on input data; make sure that are correct!

Definition at line 438 of file gameIOManager.c.

References D1, schemaProp::gameMap, schemaProp::numCol, schemaProp::numRow, and schemaData.

Referenced by newgame().

Here is the caller graph for this function:

bool readCharacters ( unsigned int *  mapCurrentCol,
unsigned int  mapMaxCol,
const unsigned int *  mapCurrentRow,
unsigned int  mapMaxRow,
char **  contentFile,
FILE *  file2read 
)

If there aren't structural form error in file and while the file not end, reads all the characters and puts it into variable contentFile.

Parameters:
mapCurrentCol column position
mapMaxCol max column length
mapCurrentRow row position
mapMaxRow max row length
contentFile content of the file
file2read pointer to the opened file to read

Definition at line 142 of file gameIOManager.c.

References D1, and ENDLINE.

Referenced by readfile().

Here is the caller graph for this function:

char** readfile ( char  namefile[],
bool *  schema_ok,
unsigned int *  mapCurrentRow,
unsigned int *  mapCurrentCol,
unsigned int  mapMaxRow,
unsigned int  mapMaxCol,
bool  differentColLen 
)

This function manages dinamic data loading processing from the configuration file.

It ignores the comments ( COMMENT ) and lines that contain less then one characters ( successives ENDLINE ). It allocates just the same memory of 'maxrow' and 'maxcol' (array of strings), because it also implements lenght controls. An addittive control, that verify if all the rows have the same number of columns, should be activate setting 'diffcontrol' to TRUE. Note: It isn't necessary to modify this function, although if the need arises to change the structure of the file. It invokes allocResetVariable, skipCharacters, readCharacters and checkDifferentColLen functions.

Returns:
A pointer to the array of strings created with the function, containing useful data of the file (char **).
Parameters:
namefile file name
schema_ok error control
mapCurrentRow row position
mapCurrentCol column position
mapMaxRow max row length
mapMaxCol max column length
differentColLen activate different columns length control

Definition at line 9 of file gameIOManager.c.

References allocResetVariable(), checkDifferentColLen(), COMMENT, D1, D2, ENDLINE, readCharacters(), and skipCharacters().

Referenced by loadCheckGame(), and readSetGameRecord().

Here is the call graph for this function:

Here is the caller graph for this function:

bool readSetGameRecord ( unsigned int *  readrows  ) 

Read from record file the record list and save it in the record data struct, invoking the functions readfile and setGameRecordStructValue.

Returns:
Positive value (true) if no errors occurs. Negative value (false) otherwise.
Parameters:
readrows Number of record read

Definition at line 211 of file gameIOManager.c.

References D1, D2, MAX_RECORD_SHOW, MAX_RECORDNAME_LEN, readfile(), RECORD_FILE_NAME, and setGameRecordStructValue().

Referenced by save_record(), and show_records().

Here is the call graph for this function:

Here is the caller graph for this function:

void save_record ( const char *  name,
unsigned int  totalpoints,
unsigned int  currentlevel 
)

Save the new record in file, invoking the function readSetGameRecord.

Warning: this function work properly with inputs composed only by letters, digits, COMMENT and ENDLINE.

Parameters:
name Player name
totalpoints Total won points
currentlevel Reached level

Definition at line 348 of file gameIOManager.c.

References D1, D2, D3, gameRecord, MAX_RECORD_SHOW, readSetGameRecord(), and RECORD_FILE_NAME.

Referenced by win().

Here is the call graph for this function:

Here is the caller graph for this function:

bool setGameRecordStructValue ( char **  filecontent,
unsigned int  numrow,
unsigned int  numcol 
)

Save the game record list into the record data structure, checking characters using function isallowedchar.

Returns:
Positive value (true) if occurs error/s. Negative value (false) otherwise.
Parameters:
filecontent Content of the file
numrow Number of rows
numcol Number of columns

Definition at line 266 of file gameIOManager.c.

References D1, DIGITS, gameRecord, isallowedchar(), gameRecordValues::level, LOWERCASE, NEW_GAME_ROUND, gameRecordValues::points, and UPPERCASE.

Referenced by readSetGameRecord().

Here is the call graph for this function:

Here is the caller graph for this function:

void skipCharacters ( char *  fileChar,
int *  checkchar,
FILE *  file2read 
)

Skips all the EOF, ENDLINE and COMMENT characters.

Parameters:
fileChar Readed character
checkchar Integer value of the readed character
file2read pointer to the opened file to read

Definition at line 124 of file gameIOManager.c.

References D1, and ENDLINE.

Referenced by readfile().

Here is the caller graph for this function:


Variable Documentation

struct gameRecordValues gameRecord[MAX_RECORD_SHOW]

Data struct containing the game's records.

Referenced by save_record(), setGameRecordStructValue(), and show_records().


Generated on Fri Apr 2 18:27:42 2010 for SMLabyrinth by  doxygen 1.5.8