Commit 73731b90 authored by Damien Lucas's avatar Damien Lucas

. Changed the way to print messages.

. You shouldn't add \n at the end of comments any more.
parent 5e13c266
......@@ -83,23 +83,23 @@ nchannels{BL}{INT} {
if (cfg->nchannels)
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : nchannels has "\
"already been defined\n",filename,line_num);
"already been defined",filename,line_num);
return VS_R_PARSE;
}
sscanf(CFG_yytext+sizeof("nchannels")/sizeof(char)-1," %lu",&ul1);
if (!ul1)
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : nchannels can't "\
"be 0\n",filename,line_num);
"be 0",filename,line_num);
return VS_R_PARSE;
}
cfg->nchannels=(VS_CHANNEL)ul1;
VS_log(LOGINFO,CFG,"Number of channels set to : %lu\n",ul1);
VS_log(LOGINFO,CFG,"Number of channels set to : %lu",ul1);
cfg->chan_map=malloc(ul1*sizeof(struct CFG_CHANNEL));
if (cfg->chan_map==NULL)
{
VS_log(LOGERROR,CFG,"Unable to allocate memory to create the channels "\
" table\n");
" table");
return VS_R_MEMORY;
}
do
......@@ -119,7 +119,7 @@ vlanbridge{BL}{IP} {
if (cfg->vlanbridge[0])
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : duplicated "\
"vlanbridge address defition\n",filename,line_num);
"vlanbridge address defition",filename,line_num);
return VS_R_PARSE;
}
for (ui1=CFG_yyleng-1;\
......@@ -134,7 +134,7 @@ vlanbridge_login{BL}{NONBLANK}+ {
if (cfg->vlanbridge_login!=NULL)
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : duplicated "\
"vlanbridge login\n",filename,line_num);
"vlanbridge login",filename,line_num);
return VS_R_PARSE;
}
for (ui1=CFG_yyleng-1;\
......@@ -143,7 +143,7 @@ vlanbridge_login{BL}{NONBLANK}+ {
if (cfg->vlanbridge_login==NULL)
{
VS_log(LOGERROR,CFG,"Unable to allocate memory to store vlanbridge "\
"login\n");
"login");
return VS_R_MEMORY;
}
memcpy(cfg->vlanbridge_login,CFG_yytext+ui1,CFG_yyleng-ui1);
......@@ -156,7 +156,7 @@ vlanbridge_password{BL}{NONBLANK}+ {
if (cfg->vlanbridge_password!=NULL)
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : duplicated "\
"vlanbridge password\n",filename,line_num);
"vlanbridge password",filename,line_num);
return VS_R_PARSE;
}
for (ui1=CFG_yyleng-1;\
......@@ -165,7 +165,7 @@ vlanbridge_password{BL}{NONBLANK}+ {
if (cfg->vlanbridge_password==NULL)
{
VS_log(LOGERROR,CFG,"Unable to allocate memory to store VLB "\
"password\n");
"password");
return VS_R_MEMORY;
}
memcpy(cfg->vlanbridge_password,CFG_yytext+ui1,CFG_yyleng-ui1);
......@@ -200,33 +200,33 @@ channel{BL}{INT}{BL}vlan{BL}{INT}{BL}protection{BL}{INT} {
if ((VS_CHANNEL)ul1>=cfg->nchannels)
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : invalid channel "\
"number\n",filename,line_num);
"number",filename,line_num);
return VS_R_PARSE;
}
if (cfg->chan_map[ul1].protection!=VS_PL_UNSPECIFIED)
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : channel %lu has"\
" already been defined\n",filename,line_num,ul1);
" already been defined",filename,line_num,ul1);
return VS_R_PARSE;
}
if ((VS_PROTECTION_LEVEL)ui1>=VS_PL_NUMBER)
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : protection levels "\
"range from 0 to %lu\n",filename,line_num,\
"range from 0 to %lu",filename,line_num,\
(unsigned long)VS_PL_NUMBER-1);
return VS_R_PARSE;
}
if (!raw_data_allowed && CFG_yyleng)
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : expecting "\
"integer\n",filename,line_num);
"integer",filename,line_num);
return VS_R_PARSE;
}
cfg->chan_map[ul1].raw_data=malloc((CFG_yyleng+1)*sizeof(char));
if (cfg->chan_map[ul1].raw_data==NULL)
{
VS_log(LOGERROR,CFG,"Unable to allocate memory to store raw data for "\
"channel %lu\n",ul1);
"channel %lu",ul1);
return VS_R_MEMORY;
}
memcpy(cfg->chan_map[ul1].raw_data,CFG_yytext,\
......@@ -237,6 +237,7 @@ channel{BL}{INT}{BL}vlan{BL}{INT}{BL}protection{BL}{INT} {
line_num++;
BEGIN(INITIAL);
eof_expected=1;
CFG_yytext[strlen(CFG_yytext)-1]='\0';
VS_log(LOGINFO,CFG,"Successfuly defined channel %lu on vlan "\
"%lu protection %u %s",ul1,ul2,ui1,CFG_yytext);
......@@ -251,7 +252,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (*st==NULL)
{
VS_log(LOGERROR,CFG,"Unable to allocate memory to create a switch "\
"type\n");
"type");
return VS_R_MEMORY;
}
(*st)->nports=(VS_PORT)0;
......@@ -271,7 +272,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if ((*st)->nports)
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : nports has "\
"already been defined\n",filename,line_num);
"already been defined",filename,line_num);
return VS_R_PARSE;
}
sscanf(CFG_yytext+sizeof("nports")/sizeof(char)-1," %lu",&ul1);
......@@ -282,7 +283,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if ((((*st)->ports)+1)==NULL)
{
VS_log(LOGERROR,CFG,"Unable to allocate memory to store a switch "\
"type's ports table\n");
"type's ports table");
return VS_R_MEMORY;
}
do
......@@ -318,7 +319,7 @@ switch{BL}type{BL}{NONBLANK}+ {
else
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : unknown switch "\
"type\n",filename,line_num);
"type",filename,line_num);
return VS_R_PARSE;
}
}
......@@ -331,7 +332,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (ui1>=VS_PL_NUMBER)
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : protection levels "\
"range from 0 to %lu\n",filename,line_num,\
"range from 0 to %lu",filename,line_num,\
(unsigned long)VS_PL_NUMBER-1);
return VS_R_PARSE;
}
......@@ -345,7 +346,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!i)
VS_log(LOGWARNING,CFG,"In %s on line %u : useless 'default' "
"statement in switch type definition, going on "
"however\n",filename,line_num);
"however",filename,line_num);
}
......@@ -355,7 +356,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!(*st)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : number of ports"
"unknown yet\n", filename, line_num);
"unknown yet", filename, line_num);
return VS_R_PARSE;
}
sscanf(CFG_yytext+sizeof("port")/sizeof(char)-1, " %lu %u", &ul1,
......@@ -363,13 +364,13 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!ul1 || (VS_PORT)ul1>(*st)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : invalid port "
"number\n", filename, line_num);
"number", filename, line_num);
return VS_R_PARSE;
}
if ((VS_PROTECTION_LEVEL)ui1>=VS_PL_NUMBER)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : protection "
"levels range from 0 to %u\n", filename, line_num,
"levels range from 0 to %u", filename, line_num,
(unsigned int)VS_PL_NUMBER-1);
return VS_R_PARSE;
}
......@@ -382,7 +383,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!(*st)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : number of ports"
"unknown yet\n", filename, line_num);
"unknown yet", filename, line_num);
}
{
unsigned int i;
......@@ -395,7 +396,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!ul1 || ul1>(*st)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : invalid "
"port number\n", filename, line_num);
"port number", filename, line_num);
return VS_R_PARSE;
}
(*st)->ports[ul1].flags|=PF_BBPORT;
......@@ -410,7 +411,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!(*st)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : number of ports"
"unknown yet\n", filename, line_num);
"unknown yet", filename, line_num);
}
{
unsigned int i;
......@@ -423,7 +424,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!ul1 || ul1>(*st)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : invalid "
"port number\n", filename, line_num);
"port number", filename, line_num);
return VS_R_PARSE;
}
(*st)->ports[ul1].flags|=PF_ATMPORT;
......@@ -438,7 +439,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!(*st)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : number of ports"
"unknown yet\n", filename, line_num);
"unknown yet", filename, line_num);
}
{
unsigned int i;
......@@ -452,7 +453,7 @@ switch{BL}type{BL}{NONBLANK}+ {
{
printf("%lu\n", ul1);
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : invalid "
"port number\n", filename, line_num);
"port number", filename, line_num);
return VS_R_PARSE;
}
(*st)->ports[ul1].flags|=PF_AOBPORT;
......@@ -467,7 +468,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!(*st)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : number of ports"
"unknown yet\n", filename, line_num);
"unknown yet", filename, line_num);
}
{
unsigned int i;
......@@ -481,7 +482,7 @@ switch{BL}type{BL}{NONBLANK}+ {
{
printf("%lu\n", ul1);
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : invalid "
"port number\n", filename, line_num);
"port number", filename, line_num);
return VS_R_PARSE;
}
(*st)->ports[ul1].flags|=PF_HUBPORT;
......@@ -497,15 +498,15 @@ switch{BL}type{BL}{NONBLANK}+ {
if ((*st)->ports[ul1].protection==VS_PL_UNSPECIFIED)
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : switch type %s "\
"has not been completely specified\n",filename,\
"has not been completely specified",filename,\
line_num,CFG_SWITCH_TYPE_NAME(**st));
return VS_R_PARSE;
}
VS_log(LOGINFO,CFG,"Switch type %s defined with the %lu following ports "\
":\n",CFG_SWITCH_TYPE_NAME(**st),\
":",CFG_SWITCH_TYPE_NAME(**st),\
(unsigned long)(*st)->nports);
for (ul1=1;(VS_PORT)ul1<=(*st)->nports;ul1++)
VS_log(LOGINFO,CFG," Port %lu :\tprotection %lu \tflags %lu\n",ul1,\
VS_log(LOGINFO,CFG," Port %lu :\tprotection %lu \tflags %lu",ul1,\
(unsigned long)(*st)->ports[ul1].protection,\
(unsigned long)(*st)->ports[ul1].flags);
st=&((*st)->next);
......@@ -524,7 +525,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (z==NULL)
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : unknown switch "\
"type\n",filename,line_num);
"type",filename,line_num);
return VS_R_PARSE;
}
CFG_yytext[i]=c;
......@@ -532,7 +533,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!VS_A2SID(CFG_yytext+i,ip))
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : invalid IP "\
"address\n",filename,line_num);
"address",filename,line_num);
return VS_R_PARSE;
}
......@@ -541,7 +542,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if(*s==NULL)
{
VS_log(LOGERROR,CFG,"Unable to allocate memory to create a new "\
"switch in the database\n");
"switch in the database");
return VS_R_MEMORY;
}
......@@ -557,7 +558,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (ports==NULL)
{
VS_log(LOGERROR,CFG,"Unable to allocate memory to create a new switch "\
"in the database\n");
"in the database");
return VS_R_MEMORY;
}
ports--;
......@@ -566,7 +567,7 @@ switch{BL}type{BL}{NONBLANK}+ {
ports[ul2].protection=z->ports[ul2].protection;
ports[ul2].flags=z->ports[ul2].flags;
}
VS_log(LOGINFO,CFG,"Creating switch %s with type %s (%lu ports)...\n",\
VS_log(LOGINFO,CFG,"Creating switch %s with type %s (%lu ports)...",\
CFG_yytext+i,CFG_SWITCH_TYPE_NAME(*z),ul2-1);
BEGIN(in_switch);
eof_expected=0;
......@@ -583,7 +584,7 @@ switch{BL}type{BL}{NONBLANK}+ {
ports++;
free(ports);
VS_log(LOGERROR,CFG,"Unable to allocate memory to store a switch's "\
"community string\n");
"community string");
return VS_R_MEMORY;
}
memcpy((*s)->community,CFG_yytext+i,CFG_yyleng-i);
......@@ -597,7 +598,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if ((VS_PORT)ul1>z->nports || !ul1)
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : invalid port "\
"number\n",filename,line_num);
"number",filename,line_num);
ports++;
free(ports);
return VS_R_PARSE;
......@@ -605,14 +606,14 @@ switch{BL}type{BL}{NONBLANK}+ {
if ((VS_PROTECTION_LEVEL)ui1>=VS_PL_NUMBER)
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : protection levels"\
"range from 0 to %u\n",filename,line_num,\
"range from 0 to %u",filename,line_num,\
(unsigned int)ui1);
ports++;
free(ports);
return VS_R_PARSE;
}
ports[ul1].protection=(VS_PROTECTION_LEVEL)ui1;
VS_log(LOGINFO,CFG," Protection of port %lu set to %u\n",ul1,ui1);
VS_log(LOGINFO,CFG," Protection of port %lu set to %u",ul1,ui1);
}
......@@ -622,7 +623,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!(*s)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : number of ports"
"unknown yet\n", filename, line_num);
"unknown yet", filename, line_num);
}
{
unsigned int i;
......@@ -635,13 +636,13 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!ul1 || ul1>(*s)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : invalid "
"port number\n", filename, line_num);
"port number", filename, line_num);
return VS_R_PARSE;
}
ports[ul1].flags|=PF_BBPORT;
}
}
VS_log(LOGINFO,CFG," Flag of port %lu set to %u\n",ul1,\
VS_log(LOGINFO,CFG," Flag of port %lu set to %u",ul1,\
ports[ul1].flags);
......@@ -653,7 +654,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!(*s)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : number of ports"
"unknown yet\n", filename, line_num);
"unknown yet", filename, line_num);
}
{
unsigned int i;
......@@ -666,13 +667,13 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!ul1 || ul1>(*s)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : invalid "
"port number\n", filename, line_num);
"port number", filename, line_num);
return VS_R_PARSE;
}
ports[ul1].flags|=PF_ATMPORT;
}
}
VS_log(LOGINFO,CFG," Flag of port %lu set to %u\n",ul1,\
VS_log(LOGINFO,CFG," Flag of port %lu set to %u",ul1,\
ports[ul1].flags);
......@@ -684,7 +685,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!(*s)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : number of ports"
"unknown yet\n", filename, line_num);
"unknown yet", filename, line_num);
}
{
unsigned int i;
......@@ -697,13 +698,13 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!ul1 || ul1>(*s)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : invalid "
"port number\n", filename, line_num);
"port number", filename, line_num);
return VS_R_PARSE;
}
ports[ul1].flags|=PF_AOBPORT;
}
}
VS_log(LOGINFO,CFG," Flag of port %lu set to %u\n",ul1,\
VS_log(LOGINFO,CFG," Flag of port %lu set to %u",ul1,\
ports[ul1].flags);
......@@ -715,7 +716,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!(*s)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : number of ports"
"unknown yet\n", filename, line_num);
"unknown yet", filename, line_num);
}
{
unsigned int i;
......@@ -729,13 +730,13 @@ switch{BL}type{BL}{NONBLANK}+ {
{
printf("%lu\n", ul1);
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : invalid "
"port number\n", filename, line_num);
"port number", filename, line_num);
return VS_R_PARSE;
}
ports[ul1].flags|=PF_HUBPORT;
}
}
VS_log(LOGINFO,CFG," Flag of port %lu set to %u\n",ul1,\
VS_log(LOGINFO,CFG," Flag of port %lu set to %u",ul1,\
ports[ul1].flags);
......@@ -747,7 +748,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!(*s)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : number of ports"
"unknown yet\n", filename, line_num);
"unknown yet", filename, line_num);
}
{
unsigned int i;
......@@ -760,13 +761,13 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!ul1 || ul1>(*s)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : invalid "
"port number\n", filename, line_num);
"port number", filename, line_num);
return VS_R_PARSE;
}
ports[ul1].flags&=~PF_BBPORT;
}
}
VS_log(LOGINFO,CFG," Flag of port %lu set to %u\n",ul1,\
VS_log(LOGINFO,CFG," Flag of port %lu set to %u",ul1,\
ports[ul1].flags);
......@@ -778,7 +779,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!(*s)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : number of ports"
"unknown yet\n", filename, line_num);
"unknown yet", filename, line_num);
}
{
unsigned int i;
......@@ -791,13 +792,13 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!ul1 || ul1>(*s)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : invalid "
"port number\n", filename, line_num);
"port number", filename, line_num);
return VS_R_PARSE;
}
ports[ul1].flags&=~PF_ATMPORT;
}
}
VS_log(LOGINFO,CFG," Flag of port %lu set to %u\n",ul1,\
VS_log(LOGINFO,CFG," Flag of port %lu set to %u",ul1,\
ports[ul1].flags);
......@@ -809,7 +810,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!(*s)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : number of ports"
"unknown yet\n", filename, line_num);
"unknown yet", filename, line_num);
}
{
unsigned int i;
......@@ -822,13 +823,13 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!ul1 || ul1>(*s)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : invalid "
"port number\n", filename, line_num);
"port number", filename, line_num);
return VS_R_PARSE;
}
ports[ul1].flags&=~PF_AOBPORT;
}
}
VS_log(LOGINFO,CFG," Flag of port %lu set to %u\n",ul1,\
VS_log(LOGINFO,CFG," Flag of port %lu set to %u",ul1,\
ports[ul1].flags);
......@@ -840,7 +841,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!(*s)->nports)
{
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : number of ports"
"unknown yet\n", filename, line_num);
"unknown yet", filename, line_num);
}
{
unsigned int i;
......@@ -854,13 +855,13 @@ switch{BL}type{BL}{NONBLANK}+ {
{
printf("%lu\n", ul1);
VS_log(LOGERROR, CFG, "Parse error in %s on line %u : invalid "
"port number\n", filename, line_num);
"port number", filename, line_num);
return VS_R_PARSE;
}
ports[ul1].flags&=~PF_HUBPORT;
}
}
VS_log(LOGINFO,CFG," Flag of port %lu set to %u\n",ul1,\
VS_log(LOGINFO,CFG," Flag of port %lu set to %u",ul1,\
ports[ul1].flags);
......@@ -872,7 +873,7 @@ switch{BL}type{BL}{NONBLANK}+ {
if ((*s)->community==NULL)
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : community string "\
"unspecified\n",filename,line_num);
"unspecified",filename,line_num);
ports++;
free(ports);
free(*s);
......@@ -892,7 +893,7 @@ switch{BL}type{BL}{NONBLANK}+ {
<*>.|\n {
VS_log(LOGERROR,CFG,"Parse error in %s on line %u\n",filename,line_num);
VS_log(LOGERROR,CFG,"Parse error in %s on line %u",filename,line_num);
if (ports+1!=NULL)
free(ports+1);
return VS_R_PARSE;
......@@ -904,12 +905,12 @@ switch{BL}type{BL}{NONBLANK}+ {
if (!eof_expected)
{
VS_log(LOGERROR,CFG,"Parse error in %s on line %u : unexpected end of "\
"file\n",filename,line_num);
"file",filename,line_num);
if (ports+1!=NULL)
free(ports+1);
return VS_R_PARSE;
}
VS_log(LOGINFO,CFG,"Parsing of %s over, %u lines parsed\n",filename,\
VS_log(LOGINFO,CFG,"Parsing of %s over, %u lines parsed",filename,\
line_num);
return 0;
......@@ -964,22 +965,22 @@ ERR_CODE CFG_init(struct VS_config *cfg,int argc,char *argv[])
filepath=argv[i];
else
{
VS_log(LOGERROR,CFG,"Expecting filename after option -f\n");
VS_log(LOGERROR,CFG,"Expecting filename after option -f");
return VS_R_PARSE;
}
}
break;
default:
VS_log(LOGERROR,CFG,"Unknown option %s\n",argv[i]);
VS_log(LOGERROR,CFG,"Unknown option %s",argv[i]);
return VS_R_PARSE;
}
else
{
VS_log(LOGERROR,CFG,"Unknown otpion %s\n",argv[i]);
VS_log(LOGERROR,CFG,"Unknown otpion %s",argv[i]);
return VS_R_PARSE;
}
VS_log(LOGINFO,CFG,"Reading configuration file %s...\n",filepath);
VS_log(LOGINFO,CFG,"Reading configuration file %s...",filepath);
cfg->nchannels=0;
cfg->chan_map=NULL;
cfg->switch_types=NULL;
......@@ -992,7 +993,7 @@ ERR_CODE CFG_init(struct VS_config *cfg,int argc,char *argv[])
ret=CFG_yylex(cfg,CFG_FILE_PATH);
else
{
VS_log(LOGERROR,CFG,"Unable to open %s\n",filepath);
VS_log(LOGERROR,CFG,"Unable to open %s",filepath);
return VS_R_FILE;
}
if (fclose(CFG_yyin))
......@@ -1001,6 +1002,6 @@ ERR_CODE CFG_init(struct VS_config *cfg,int argc,char *argv[])
if (ret)
cleanup(cfg);
else
VS_log(LOGINFO,CFG,"Setup successfuly terminated\n");
VS_log(LOGINFO,CFG,"Setup successfuly terminated");
return ret;
}
......@@ -405,13 +405,13 @@ static void * DB_machines_loop(struct DB_db * db)
{
struct DB_M_request * z;
VS_log(LOGINFO, DB, "Machines loop started\n");
VS_log(LOGINFO, DB, "Machines loop started");
pthread_mutex_lock(&db->db_lock);
pthread_mutex_unlock(&db->db_lock);
pthread_mutex_destroy(&db->db_lock);
if (db->runlevel==DB_CANCEL)
{
VS_log(LOGERROR, DB, "Machines loop canceled\n");
VS_log(LOGERROR, DB, "Machines loop canceled");
return NULL;
}
while (db->runlevel<DB_STOP)
......@@ -431,7 +431,7 @@ static void * DB_machines_loop(struct DB_db * db)
pthread_mutex_unlock(&db->machines_requests_lock);
}
}
VS_log(LOGINFO, DB, "Machines loop stopped\n");
VS_log(LOGINFO, DB, "Machines loop stopped");
return NULL;
}
......@@ -444,7 +444,7 @@ static void * DB_switchs_loop(struct DB_db * db)
{
struct DB_S_request * z;
VS_log(LOGINFO, DB, "Switchs loop started\n");
VS_log(LOGINFO, DB, "Switchs loop started");
while (db->runlevel<DB_STOP)
{
pthread_mutex_lock(&db->switchs_requests_lock);
......@@ -461,7 +461,7 @@ static void * DB_switchs_loop(struct DB_db * db)
pthread_mutex_unlock(&db->switchs_requests_lock);
}
}
VS_log(LOGINFO,DB,"Switchs loop stopped\n");
VS_log(LOGINFO,DB,"Switchs loop stopped");
return NULL;
}
......@@ -479,7 +479,7 @@ static void DB_cancel(struct DB_db * db)
pthread_mutex_destroy(&db->switchs_requests_lock);
pthread_cond_destroy(&db->machines_requests_cond);
pthread_cond_destroy(&db->switchs_requests_cond);
VS_log(LOGERROR,DB,"Unable to spawn the database engine\n");
VS_log(LOGERROR,DB,"Unable to spawn the database engine");
}
/******************************************************************************/
......@@ -496,7 +496,7 @@ ERR_CODE DB_start(struct DB_db * db)
{
unsigned int i;
VS_log(LOGINFO, DB, "Starting the database engine...\n");
VS_log(LOGINFO, DB, "Starting the database engine...");
db->runlevel=DB_INIT;
pthread_mutex_init(&db->machines_requests_lock, NULL);
pthread_mutex_init(&db->switchs_requests_lock, NULL);
......@@ -525,7 +525,7 @@ ERR_CODE DB_start(struct DB_db * db)
}
db->runlevel=DB_RUN;
pthread_mutex_unlock(&db->db_lock);
VS_log(LOGINFO, DB, "Database engine successfuly started\n");
VS_log(LOGINFO, DB, "Database engine successfuly started");
return 0;
}
......@@ -607,7 +607,7 @@ ERR_CODE DB_switchs_insert(struct DB_db * db, VS_SwitchId ip,
}
}
}
VS_log(LOGINFO,DB,"Switch %s successfuly created\n",VS_SID2A(ip));
VS_log(LOGINFO,DB,"Switch %s successfuly created",VS_SID2A(ip));
return req.ret_value;
}
else
......
......@@ -31,7 +31,7 @@ char * VS_log_errstr(ERR_CODE err)
ERR_CODE VS_log(LOG_LEVELS level, LOG_MODULES module, char* format, ...)
{
va_list ap;
char MsgBuff[LOGBUFF_MAXSIZE];
char MsgBuff[LOGBUFF_MAXSIZE+20];
time_t MsgTime;
struct tm * ptmTime;
......@@ -81,10 +81,11 @@ ERR_CODE VS_log(LOG_LEVELS level, LOG_MODULES module, char* format, ...)
sprintf(MsgBuff+strlen(MsgBuff), "FATAL ] ");
break;
}
/* XXX No error checking ! What length is the message ? */
va_start(ap, format);
vsnprintf(MsgBuff+strlen(MsgBuff), LOGBUFF_MAXSIZE, format, ap);
sprintf(MsgBuff+strlen(MsgBuff), "\n");
va_end(ap);
printf("%s", MsgBuff);
......
......@@ -22,7 +22,7 @@ int main(int argc,char *argv[])
rc=VS_init(&vs,argc,argv);
if (rc)
{
VS_log(LOGFATAL,SERVER,"%s\n",VS_log_errstr(rc));
VS_log(LOGFATAL,SERVER,"%s",VS_log_errstr(rc));
return rc;
}
return 0;
......
......@@ -77,7 +77,7 @@ int VS_client(VS_CHANNEL Channel_dest)
* Looking for the interface MAC address
*/
ioctl(socket_cl,SIOCGIFHWADDR,&interface);
VS_log(LOGDEBUG,SERVER,"macaddr == %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x\n",
VS_log(LOGDEBUG,SERVER,"macaddr == %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x",
interface.ifr_hwaddr.sa_data[0] & 0xff,
interface.ifr_hwaddr.sa_data[1] & 0xff,
interface.ifr_hwaddr.sa_data[2] & 0xff,
......@@ -91,7 +91,7 @@ int VS_client(VS_CHANNEL Channel_dest)
date_cl=malloc(sizeof(struct timeval));
if(date_cl==NULL)
{
VS_log(LOGERROR,SERVER,"Unable to allocate memory\n");
VS_log(LOGERROR,SERVER,"Unable to allocate memory");
return VS_R_MEMORY;
}
......@@ -99,7 +99,7 @@ int VS_client(VS_CHANNEL Channel_dest)
return -1;
date=date_cl->tv_sec;
free(date_cl);
VS_log(LOGDEBUG,SERVER,"Date %lu\n",date);
VS_log(LOGDEBUG,SERVER,"Date %lu",date);
/*
......@@ -114,7 +114,7 @@ int VS_client(VS_CHANNEL Channel_dest)
interface.ifr_hwaddr.sa_data[4] & 0xff,
interface.ifr_hwaddr.sa_data[5] & 0xff);
VS_log(LOGDEBUG,SERVER,"The message is %s\n",mess);
VS_log(LOGDEBUG,SERVER,"The message is %s",mess);
/*
......@@ -128,7 +128,7 @@ int VS_client(VS_CHANNEL Channel_dest)
rc=bind(socket_cl,(struct sockaddr *)(&sa_client),sizeof(struct sockaddr));
if (rc)
{
VS_log(LOGDEBUG,SERVER,"Unable to bind socket:%u\n",rc);
VS_log(LOGDEBUG,SERVER,"Unable to bind socket:%u",rc);
// TODO mettre un VS_R_BIND dans types.h
return VS_R_SOCKET;
}
......@@ -150,28 +150,28 @@ int VS_client(VS_CHANNEL Channel_dest)
nbanswer=select(socket_cl+1,&rfds,NULL,NULL,&time);
if(nbanswer==0)
{
VS_log(LOGDEBUG,SERVER,"No answer\n");
VS_log(LOGDEBUG,SERVER,"No answer");
}
else if(nbanswer==-1)
{
VS_log(LOGDEBUG,SERVER,"Unable to receive the answer\n");
VS_log(LOGDEBUG,SERVER,"Unable to receive the answer");
}