innanzitutto vorrei ringraziarti per il tuo interessamento
appresso c'è il file dove ho dichiarato le strutture e le variabili globali come output_dirname e output.
spero che tu possa capirci qualcosa.
codice:
/*********************************************************
generator.h: complex type definitions and functions
**********************************************************/
#ifndef GENERATOR_HEADER
#define GENERATOR_HEADER
/*********************************************************
Constants Definition
**********************************************************/
#define CONSTANTS_FORMATSTR "%s\\constants.data"
#define SIZES_FORMATSTR "%s\\sizes.data"
#define NODES_FORMATSTR "%s\\nodes.data"
#define ROUTING_FORMATSTR "%s\\routing.data"
#define CAPPOWLEVELS_FORMATSTR "%s\\cappowlevels.data"
/*********************************************************
Global Variables Definiton
**********************************************************/
int NNODES;
FILE *streama;
char constants_filename[100],
sizes_filename[100],
nodes_filename[100],
routing_filename[100],
cappowlevels_filename[100];
char *output_dirname;
char output;
char parameters_file[60];
int argc;
char* argv;
char commento[1024];
/*********************************************************
Complex Type Definition
**********************************************************/
struct gendimension_data
{
double delta;
double W;
double radius;
double lambda;
double netdia;
int max_levelnum;
double max_power;
double min_power;
double max_capacity;
double min_capacity;
double max_powercost;
double min_powercost;
float max_penalty;
int max_ratequantity;
};
typedef struct gendimension_data GENDIMDATA;
typedef GENDIMDATA* GENDIMDATA_PTR;
//lista delle coordinate
struct listcoord
{
double ascissa;
double ordinata;
struct listcoord* listcoordptr;
}listcoord;
typedef struct listcoord LISTCOORD;
typedef LISTCOORD* LISTCOORD_PTR;
// struttura path
struct path
{
int source;
int destination;
int length;
float penalty;
int rate_quantity;
int n_path;
}routing;
typedef struct path PATH;
//constants
struct netinfo_const
{
double delta;
double W;
double radius;
double lambda;
double netdia; // Network Diameter
};
typedef struct netinfo_const NICONST;
typedef NICONST* NICONST_PTR;
//size
struct netinfo_size
{
int NNODES;
int COUPLE_NUM;
int POWERLEVELS_NUM;
int CAPACITYLEVELS_NUM;
};
typedef struct netinfo_size NISIZE;
typedef NISIZE* NISIZE_PTR;
//data
struct netinfo_data
{
double** ncoord_mtx;
PATH* routing_array;
double* powercost_array;
double** pathcouple_mtx;
double* powerlevel_array;
double* capacitylevel_array;
double** normconst_mtx;
double* sigma_array;
};
typedef struct netinfo_data NIDATA;
typedef NIDATA* NIDATA_PTR;
/*********************************************************
List of Functions
**********************************************************/
//FUNZIONI DI INIZIALIZZAZIONE E DI LETTURA
//funzione che legge genparameter.data
GENDIMDATA_PTR read_genparameter(FILE* streama);
//funzione che inizializza la lista delle coordinate
LISTCOORD_PTR listcoord_init();
//funzione che alloca la struttura netinfo.data
//NIDATA_PTR allocate_netdata(NISIZE_PTR size);
//FUNZIONI DI GENERAZIONE
//funzione che genera (pseudo)casualmente un numero intero compreso tra 0 e RAND_MAX
int random();
//funzione che crea la struttura netinfo_costs (delta, W, radius, lambda, netdia)
NICONST_PTR netinfoconst_create(GENDIMDATA_PTR gendimdata_ptr);
//funzione che genera di size.data(NNODES, COUPLE_NUM, POWERLEVELS_NUM, CAPACITYLEVELS_NUM (3 int)
NISIZE_PTR netinfosize_generation(int NNODES, GENDIMDATA_PTR gendimdata_ptr);
//funzione che genera una coppia di coordinate comprese tra 0 e max_dim
LISTCOORD_PTR ncoord_couple_generation(NICONST_PTR const_ptr);
//funzione che inserisce le coordinate nella lista controllando la sovrapposizione e l'isolamento
LISTCOORD_PTR ncoord_insert(LISTCOORD_PTR listcoord_ptr, LISTCOORD_PTR newlistcoord_ptr, NICONST_PTR consts_ptr);
//funzione che alloca e genera netdata
NIDATA_PTR generate_netdata(NICONST_PTR consts, NISIZE_PTR size, GENDIMDATA_PTR gendimdata_ptr, LISTCOORD_PTR new_list_coord);
//funzione che genera di nodes.data (ncoord_mtx, powercost_array, normconst_mtx, sigma_array)
//NIDATA_PTR nodes_generation(int NNODES, NIDATA_PTR data_ptr, NICONST_PTR consts_ptr, GENDIMDATA_PTR gen_ptr);
//funzione di generazione di powerlevel_array
//NIDATA_PTR powerlevel_array_generation(NIDATA_PTR data, NISIZE_PTR size, GENDIMDATA_PTR gendimedata_ptr);
//funzione di generazione di capacitylevel_array
//NIDATA_PTR capacitylevel_array_generation(NIDATA_PTR data, NISIZE_PTR size, GENDIMDATA_PTR gendimedata_ptr);
//generazione routing.data
//NIDATA_PTR routing_array_generation(int NNODES, NIDATA_PTR data, NISIZE_PTR size, GENDIMDATA_PTR gendimdataptr);
//FUNZIONI DI SCRITTURA
//scrittura del file constants.data
int write_constants_data(char* filename, NICONST_PTR consts_ptr);
//scrittura del file sizes.data
int write_sizes_data(char* filename, NISIZE_PTR size);
//scrittura del file nodes.data
int write_nodes_data(char* filename, int NNODES, NIDATA_PTR data);
//scrittura del file routing.data
int write_routing_data(char* filename, NIDATA_PTR data, NISIZE_PTR size);
//scrittura del file cappowlevels.data
int write_cappowlevels_data (char* filename, NIDATA_PTR data, NISIZE_PTR size);
#endif