Corewar documentation 1.0.0
Loading...
Searching...
No Matches
corewar.h File Reference

The header of the corewar project. More...

#include "mymemory.h"
#include "myop.h"

Go to the source code of this file.

Data Structures

struct  cell_s
 The cell structure. More...
 
struct  champion_s
 The champion structure. More...
 
struct  corewar_s
 The corewar structure. More...
 

Typedefs

typedef struct cell_s cell_t
 The cell structure.
 
typedef struct champion_s champion_t
 The champion structure.
 
typedef struct corewar_s corewar_t
 The corewar structure.
 

Functions

corewar_tget_corewar (void)
 Get the corewar object.
 
void free_corewar (void)
 Free the corewar structure.
 
int corewar (void)
 The virtual machine of the corewar.
 
int parse_args (int argc, char **argv)
 Parse the arguments.
 
int get_next_champion_number (void)
 Get the next champion number disponible.
 
int champion_number_exist (int number)
 Check if a champion number exist.
 
int analyse_champions (void)
 Analyse each champion files and complete the champion structure.
 
char * read_file (char *filepath, int size, int start)
 Read a file and return the content.
 
int get_prog_size (char *header)
 Get the program size.
 
int is_valid_magic (char *header)
 Check if the magic number is valid.
 
void build_arena (void)
 Build the arena.
 
void display_arena (void)
 Display the arena.
 

Detailed Description

The header of the corewar project.

Typedef Documentation

◆ cell_t

typedef struct cell_s cell_t

The cell structure.

Note
A cell is a memory case of the arena

Function Documentation

◆ analyse_champions()

int analyse_champions ( void )

Analyse each champion files and complete the champion structure.

Returns
int 0 if the analyse is a success, 84 otherwise

◆ build_arena()

void build_arena ( void )

Build the arena.

Returns
void

◆ champion_number_exist()

int champion_number_exist ( int number)

Check if a champion number exist.

Parameters
numberThe champion number
Returns
int 1 if the champion number exist, 0 otherwise

◆ corewar()

int corewar ( void )

The virtual machine of the corewar.

Returns
int 0 if the corewar is running, 84 otherwise

◆ display_arena()

void display_arena ( void )

Display the arena.

Returns
void

◆ free_corewar()

void free_corewar ( void )

Free the corewar structure.

Free the corewar structure and all the memory allocated.

Returns
void

Free the corewar structure.

Returns
void

◆ get_corewar()

corewar_t * get_corewar ( void )

Get the corewar object.

Get the corewar structure.

Returns
corewar_t*
corewar_t* The corewar structure

Get the corewar object.

Returns
corewar_t* The corewar structure

◆ get_next_champion_number()

int get_next_champion_number ( void )

Get the next champion number disponible.

Returns
int The next champion number

◆ get_prog_size()

int get_prog_size ( char * header)

Get the program size.

Parameters
headerThe header of the program
Returns
int The program size

◆ is_valid_magic()

int is_valid_magic ( char * header)

Check if the magic number is valid.

Parameters
headerThe header of the program
Returns
int 1 if the magic number is valid, 0 otherwise

◆ parse_args()

int parse_args ( int argc,
char ** argv )

Parse the arguments.

Parameters
argcThe number of arguments
argvThe arguments
Returns
int 0 if the parsing is a success, 84 otherwise

◆ read_file()

char * read_file ( char * filepath,
int size,
int start )

Read a file and return the content.

Parameters
filepathThe file path
sizeThe size of the bytes to read
startThe start of the reading
Returns
char* The content of the file or NULL if an error occurred