Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb13ffd3

Browse files
author
Bryan Henderson
committed
Add our own copy of inet_aton() for sparc_solaris, which doesn't have it in
the standard C library.
1 parentb0d6f0a commitb13ffd3

File tree

3 files changed

+170
-5
lines changed

3 files changed

+170
-5
lines changed

‎src/backend/port/Makefile

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,17 @@
99
#
1010
# make SUBSYS.o PORTNAME=linux
1111
#
12+
# We have two different modes of operation: 1) put stuff specific to Port X
13+
# in subdirectory X and have that subdirectory's make file make it all, and
14+
# 2) use conditional statements in the present make file to include what's
15+
# necessary for a specific port in our own output. (1) came first, but (2)
16+
# is superior for many things, like when the same thing needs to be done for
17+
# multiple ports and you don't want to duplicate files in multiple
18+
# subdirectories. Much of the stuff done via Method 1 today should probably
19+
# be converted to Method 2.
20+
#
1221
# IDENTIFICATION
13-
# $Header: /cvsroot/pgsql/src/backend/port/Makefile,v 1.1 1996/10/27 09:49:14 bryanh Exp $
22+
# $Header: /cvsroot/pgsql/src/backend/port/Makefile,v 1.2 1996/10/28 09:00:52 bryanh Exp $
1423
#
1524
#-------------------------------------------------------------------------
1625

@@ -20,18 +29,32 @@ ifndef PORTNAME
2029
@false
2130
else
2231

32+
OBJS =
33+
34+
ifeq ($(PORTNAME), sparc_solaris)
35+
# Other ports get the inet_aton() function from their standard C libraries.
36+
OBJS += inet_aton.o
37+
endif
38+
2339
all: SUBSYS.o
2440

25-
SUBSYS.o:
41+
SUBSYS.o:$(PORTNAME)/SUBSYS.o$(OBJS)
42+
$(LD) -r -o SUBSYS.o$(PORTNAME)/SUBSYS.o$(OBJS)
43+
44+
$(PORTNAME)/SUBSYS.o:
2645
$(MAKE) -C$(PORTNAME) SUBSYS.o
27-
cp$(PORTNAME)/SUBSYS.o.
2846

2947
clean:
30-
rm -fSUBSYS.o
48+
rm -f$(OBJS)
3149
$(MAKE) -C$(PORTNAME) clean
3250

33-
.DEFAULT:
51+
dependdep:
52+
$(CC) -MM$(INCLUDE_OPT)*.c>depend
3453
$(MAKE) -C$(PORTNAME)$@
3554

55+
ifeq (depend,$(wildcard depend))
56+
include depend
57+
endif
3658

3759
endif
60+

‎src/backend/port/inet_aton.c

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/*
2+
3+
This inet_aton() function was taken from the GNU C library and
4+
incorporated into Postgres for those systems which do not have this
5+
routine in their standard C libraries.
6+
7+
The function was been extracted whole from the file inet_aton.c in
8+
Release 5.3.12 of the Linux C library, which is derived from the
9+
GNU C library, by Bryan Henderson in October 1996. The copyright
10+
notice from that file is below.
11+
*/
12+
/*
13+
* Copyright (c) 1983, 1990, 1993
14+
*The Regents of the University of California. All rights reserved.
15+
*
16+
* Redistribution and use in source and binary forms, with or without
17+
* modification, are permitted provided that the following conditions
18+
* are met:
19+
* 1. Redistributions of source code must retain the above copyright
20+
* notice, this list of conditions and the following disclaimer.
21+
* 2. Redistributions in binary form must reproduce the above copyright
22+
* notice, this list of conditions and the following disclaimer in the
23+
* documentation and/or other materials provided with the distribution.
24+
* 3. All advertising materials mentioning features or use of this software
25+
* must display the following acknowledgement:
26+
*This product includes software developed by the University of
27+
*California, Berkeley and its contributors.
28+
* 4. Neither the name of the University nor the names of its contributors
29+
* may be used to endorse or promote products derived from this software
30+
* without specific prior written permission.
31+
*
32+
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
33+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35+
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
36+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
41+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42+
* SUCH DAMAGE. */
43+
44+
#include<netinet/in.h>
45+
#include<ctype.h>
46+
#include"inet_aton.h"
47+
48+
/*
49+
* Check whether "cp" is a valid ascii representation
50+
* of an Internet address and convert to a binary address.
51+
* Returns 1 if the address is valid, 0 if not.
52+
* This replaces inet_addr, the return value from which
53+
* cannot distinguish between failure and a local broadcast address.
54+
*/
55+
int
56+
inet_aton(constchar*cp,structin_addr*addr)
57+
{
58+
registeru_longval;
59+
registerintbase,n;
60+
registercharc;
61+
u_intparts[4];
62+
registeru_int*pp=parts;
63+
64+
for (;;) {
65+
/*
66+
* Collect number up to ``.''.
67+
* Values are specified as for C:
68+
* 0x=hex, 0=octal, other=decimal.
69+
*/
70+
val=0;base=10;
71+
if (*cp=='0') {
72+
if (*++cp=='x'||*cp=='X')
73+
base=16,cp++;
74+
else
75+
base=8;
76+
}
77+
while ((c=*cp)!='\0') {
78+
if (isascii(c)&&isdigit(c)) {
79+
val= (val*base)+ (c-'0');
80+
cp++;
81+
continue;
82+
}
83+
if (base==16&&isascii(c)&&isxdigit(c)) {
84+
val= (val <<4)+
85+
(c+10- (islower(c) ?'a' :'A'));
86+
cp++;
87+
continue;
88+
}
89+
break;
90+
}
91+
if (*cp=='.') {
92+
/*
93+
* Internet format:
94+
*a.b.c.d
95+
*a.b.c(with c treated as 16-bits)
96+
*a.b(with b treated as 24 bits)
97+
*/
98+
if (pp >=parts+3||val>0xff)
99+
return (0);
100+
*pp++=val,cp++;
101+
}else
102+
break;
103+
}
104+
/*
105+
* Check for trailing characters.
106+
*/
107+
if (*cp&& (!isascii(*cp)|| !isspace(*cp)))
108+
return (0);
109+
/*
110+
* Concoct the address according to
111+
* the number of parts specified.
112+
*/
113+
n=pp-parts+1;
114+
switch (n) {
115+
116+
case1:/* a -- 32 bits */
117+
break;
118+
119+
case2:/* a.b -- 8.24 bits */
120+
if (val>0xffffff)
121+
return (0);
122+
val |=parts[0] <<24;
123+
break;
124+
125+
case3:/* a.b.c -- 8.8.16 bits */
126+
if (val>0xffff)
127+
return (0);
128+
val |= (parts[0] <<24) | (parts[1] <<16);
129+
break;
130+
131+
case4:/* a.b.c.d -- 8.8.8.8 bits */
132+
if (val>0xff)
133+
return (0);
134+
val |= (parts[0] <<24) | (parts[1] <<16) | (parts[2] <<8);
135+
break;
136+
}
137+
if (addr)
138+
addr->s_addr=htonl(val);
139+
return (1);
140+
}

‎src/backend/port/inet_aton.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
int
2+
inet_aton(constchar*cp,structin_addr*addr);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp