Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
b04e3a25
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b04e3a25
编写于
8月 21, 2001
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove special-case treatment of all-zeroes MAC address, per today's
discussion in pgsql-general.
上级
5db5c2db
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
26 addition
and
41 deletion
+26
-41
src/backend/utils/adt/mac.c
src/backend/utils/adt/mac.c
+26
-41
未找到文件。
src/backend/utils/adt/mac.c
浏览文件 @
b04e3a25
/*
* PostgreSQL type definitions for MAC addresses.
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/mac.c,v 1.2
0 2001/03/22 03:59:51 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/mac.c,v 1.2
1 2001/08/21 21:23:21 tgl
Exp $
*/
#include "postgres.h"
...
...
@@ -28,40 +28,32 @@ Datum
macaddr_in
(
PG_FUNCTION_ARGS
)
{
char
*
str
=
PG_GETARG_CSTRING
(
0
);
macaddr
*
result
;
int
a
,
b
,
c
,
d
,
e
,
f
;
macaddr
*
result
;
int
count
;
if
(
strlen
(
str
)
>
0
)
{
count
=
sscanf
(
str
,
"%x:%x:%x:%x:%x:%x"
,
&
a
,
&
b
,
&
c
,
&
d
,
&
e
,
&
f
);
if
(
count
!=
6
)
count
=
sscanf
(
str
,
"%x-%x-%x-%x-%x-%x"
,
&
a
,
&
b
,
&
c
,
&
d
,
&
e
,
&
f
);
if
(
count
!=
6
)
count
=
sscanf
(
str
,
"%2x%2x%2x:%2x%2x%2x"
,
&
a
,
&
b
,
&
c
,
&
d
,
&
e
,
&
f
);
if
(
count
!=
6
)
count
=
sscanf
(
str
,
"%2x%2x%2x-%2x%2x%2x"
,
&
a
,
&
b
,
&
c
,
&
d
,
&
e
,
&
f
);
if
(
count
!=
6
)
count
=
sscanf
(
str
,
"%2x%2x.%2x%2x.%2x%2x"
,
&
a
,
&
b
,
&
c
,
&
d
,
&
e
,
&
f
);
if
(
count
!=
6
)
elog
(
ERROR
,
"macaddr_in: error in parsing
\"
%s
\"
"
,
str
);
if
((
a
<
0
)
||
(
a
>
255
)
||
(
b
<
0
)
||
(
b
>
255
)
||
(
c
<
0
)
||
(
c
>
255
)
||
(
d
<
0
)
||
(
d
>
255
)
||
(
e
<
0
)
||
(
e
>
255
)
||
(
f
<
0
)
||
(
f
>
255
))
elog
(
ERROR
,
"macaddr_in: illegal address
\"
%s
\"
"
,
str
);
}
else
{
a
=
b
=
c
=
d
=
e
=
f
=
0
;
/* special case for missing
* address */
}
count
=
sscanf
(
str
,
"%x:%x:%x:%x:%x:%x"
,
&
a
,
&
b
,
&
c
,
&
d
,
&
e
,
&
f
);
if
(
count
!=
6
)
count
=
sscanf
(
str
,
"%x-%x-%x-%x-%x-%x"
,
&
a
,
&
b
,
&
c
,
&
d
,
&
e
,
&
f
);
if
(
count
!=
6
)
count
=
sscanf
(
str
,
"%2x%2x%2x:%2x%2x%2x"
,
&
a
,
&
b
,
&
c
,
&
d
,
&
e
,
&
f
);
if
(
count
!=
6
)
count
=
sscanf
(
str
,
"%2x%2x%2x-%2x%2x%2x"
,
&
a
,
&
b
,
&
c
,
&
d
,
&
e
,
&
f
);
if
(
count
!=
6
)
count
=
sscanf
(
str
,
"%2x%2x.%2x%2x.%2x%2x"
,
&
a
,
&
b
,
&
c
,
&
d
,
&
e
,
&
f
);
if
(
count
!=
6
)
elog
(
ERROR
,
"macaddr_in: error in parsing
\"
%s
\"
"
,
str
);
if
((
a
<
0
)
||
(
a
>
255
)
||
(
b
<
0
)
||
(
b
>
255
)
||
(
c
<
0
)
||
(
c
>
255
)
||
(
d
<
0
)
||
(
d
>
255
)
||
(
e
<
0
)
||
(
e
>
255
)
||
(
f
<
0
)
||
(
f
>
255
))
elog
(
ERROR
,
"macaddr_in: illegal address
\"
%s
\"
"
,
str
);
result
=
(
macaddr
*
)
palloc
(
sizeof
(
macaddr
));
...
...
@@ -87,20 +79,13 @@ macaddr_out(PG_FUNCTION_ARGS)
result
=
(
char
*
)
palloc
(
32
);
if
((
hibits
(
addr
)
>
0
)
||
(
lobits
(
addr
)
>
0
))
{
sprintf
(
result
,
"%02x:%02x:%02x:%02x:%02x:%02x"
,
addr
->
a
,
addr
->
b
,
addr
->
c
,
addr
->
d
,
addr
->
e
,
addr
->
f
);
}
else
{
result
[
0
]
=
'\0'
;
/* special case for missing address */
}
sprintf
(
result
,
"%02x:%02x:%02x:%02x:%02x:%02x"
,
addr
->
a
,
addr
->
b
,
addr
->
c
,
addr
->
d
,
addr
->
e
,
addr
->
f
);
PG_RETURN_CSTRING
(
result
);
}
/*
macaddr_text()
/*
* Convert macaddr to text data type.
*/
...
...
@@ -127,15 +112,15 @@ macaddr_text(PG_FUNCTION_ARGS)
PG_RETURN_TEXT_P
(
result
);
}
/*
text_macaddr()
/*
* Convert text to macaddr data type.
*/
Datum
text_macaddr
(
PG_FUNCTION_ARGS
)
{
Datum
result
;
text
*
addr
=
PG_GETARG_TEXT_P
(
0
);
Datum
result
;
char
str
[
18
];
int
len
;
...
...
@@ -143,7 +128,7 @@ text_macaddr(PG_FUNCTION_ARGS)
if
(
len
>=
18
)
elog
(
ERROR
,
"Text is too long to convert to MAC address"
);
mem
move
(
str
,
VARDATA
(
addr
),
len
);
mem
cpy
(
str
,
VARDATA
(
addr
),
len
);
*
(
str
+
len
)
=
'\0'
;
result
=
DirectFunctionCall1
(
macaddr_in
,
CStringGetDatum
(
str
));
...
...
@@ -255,8 +240,8 @@ hashmacaddr(PG_FUNCTION_ARGS)
Datum
macaddr_trunc
(
PG_FUNCTION_ARGS
)
{
macaddr
*
result
;
macaddr
*
addr
=
PG_GETARG_MACADDR_P
(
0
);
macaddr
*
result
;
result
=
(
macaddr
*
)
palloc
(
sizeof
(
macaddr
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录