MOD aaa-12 解决显示接口角色过长的问题
SOL 解决显示接口角色过长的问题 修改人:zhangliang 检视人:zhangliang
This commit is contained in:
parent
996ecfdd05
commit
11d319ed50
|
@ -11,8 +11,6 @@
|
|||
#include "netconfig.h"
|
||||
#include "parsefile.h"
|
||||
|
||||
|
||||
|
||||
static char *if_parse_name(char *name, char *p)
|
||||
{
|
||||
while (isspace(*p))
|
||||
|
@ -40,6 +38,34 @@ static char *if_parse_name(char *name, char *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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
char start_str[IF_BUFF_LEN] = {0};
|
||||
char *start_ptr = conf_buff;
|
||||
char *p;
|
||||
|
||||
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");
|
||||
|
||||
while(*p != '\0' && isspace(*p))
|
||||
while(*p != '\0' && *p != '\n')
|
||||
{
|
||||
p++;
|
||||
}
|
||||
if(*p != '\0')
|
||||
{
|
||||
strncpy(conf_buff, p, buff_len - 1);
|
||||
return RET_OK;
|
||||
if(isspace(*p))
|
||||
{
|
||||
p++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(conf_buff - start_ptr >= buff_len - 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
*(conf_buff++) = *(p++);
|
||||
}
|
||||
|
||||
*conf_buff = '\0';
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue