MOD aaa-12 解决显示接口角色过长的问题
SOL 解决显示接口角色过长的问题 修改人:zhangliang 检视人:zhangliang
This commit is contained in:
parent
996ecfdd05
commit
11d319ed50
|
@ -11,8 +11,6 @@
|
||||||
#include "netconfig.h"
|
#include "netconfig.h"
|
||||||
#include "parsefile.h"
|
#include "parsefile.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static char *if_parse_name(char *name, char *p)
|
static char *if_parse_name(char *name, char *p)
|
||||||
{
|
{
|
||||||
while (isspace(*p))
|
while (isspace(*p))
|
||||||
|
@ -40,6 +38,34 @@ static char *if_parse_name(char *name, char *p)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *if_parse_name(char *name, char *p)
|
||||||
|
{
|
||||||
|
while (isspace(*p))
|
||||||
|
p++;
|
||||||
|
while (*p) {
|
||||||
|
if (isspace(*p))
|
||||||
|
break;
|
||||||
|
if (*p == ':') { /* could be an alias */
|
||||||
|
char *dot = p, *dotname = name;
|
||||||
|
*name++ = *p++;
|
||||||
|
while (isdigit(*p))
|
||||||
|
*name++ = *p++;
|
||||||
|
if (*p != ':') { /* it wasn't, backup */
|
||||||
|
p = dot;
|
||||||
|
name = dotname;
|
||||||
|
}
|
||||||
|
if (*p == '\0')
|
||||||
|
return NULL;
|
||||||
|
p++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*name++ = *p++;
|
||||||
|
}
|
||||||
|
*name++ = '\0';
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int procnetdev_version(char *buf)
|
static int procnetdev_version(char *buf)
|
||||||
{
|
{
|
||||||
if (strstr(buf, "compressed"))
|
if (strstr(buf, "compressed"))
|
||||||
|
@ -1043,6 +1069,7 @@ ret_code if_default_role_get(char *if_name, char *conf_buff, int buff_len)
|
||||||
ret_code if_role_file_get(char *if_name, char *conf_buff, int buff_len)
|
ret_code if_role_file_get(char *if_name, char *conf_buff, int buff_len)
|
||||||
{
|
{
|
||||||
char start_str[IF_BUFF_LEN] = {0};
|
char start_str[IF_BUFF_LEN] = {0};
|
||||||
|
char *start_ptr = conf_buff;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
sprintf(start_str, "interface %s", if_name);
|
sprintf(start_str, "interface %s", if_name);
|
||||||
|
@ -1052,15 +1079,25 @@ ret_code if_role_file_get(char *if_name, char *conf_buff, int buff_len)
|
||||||
{
|
{
|
||||||
p = conf_buff + strlen("role");
|
p = conf_buff + strlen("role");
|
||||||
|
|
||||||
while(*p != '\0' && isspace(*p))
|
while(*p != '\0' && *p != '\n')
|
||||||
|
{
|
||||||
|
if(isspace(*p))
|
||||||
{
|
{
|
||||||
p++;
|
p++;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if(*p != '\0')
|
|
||||||
|
if(conf_buff - start_ptr >= buff_len - 1)
|
||||||
{
|
{
|
||||||
strncpy(conf_buff, p, buff_len - 1);
|
break;
|
||||||
return RET_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*(conf_buff++) = *(p++);
|
||||||
|
}
|
||||||
|
|
||||||
|
*conf_buff = '\0';
|
||||||
|
|
||||||
|
return RET_OK;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue