Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
6afca9c5
Commit
6afca9c5
authored
24 years ago
by
Fredrik Hübinette (Hubbe)
Browse files
Options
Downloads
Patches
Plain Diff
NO_PIKE_SHORTHAND
Rev: src/modules/files/socket.c:1.50
parent
6a4bfa36
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/modules/files/socket.c
+24
-22
24 additions, 22 deletions
src/modules/files/socket.c
with
24 additions
and
22 deletions
src/modules/files/socket.c
+
24
−
22
View file @
6afca9c5
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
||| Pike is distributed as GPL (General Public License)
||| Pike is distributed as GPL (General Public License)
||| See the files COPYING and DISCLAIMER for more information.
||| See the files COPYING and DISCLAIMER for more information.
\*/
\*/
#define NO_PIKE_SHORTHAND
#include
"global.h"
#include
"global.h"
#include
"fdlib.h"
#include
"fdlib.h"
#include
"interpret.h"
#include
"interpret.h"
...
@@ -19,7 +21,7 @@
...
@@ -19,7 +21,7 @@
#include
"file_machine.h"
#include
"file_machine.h"
#include
"file.h"
#include
"file.h"
RCSID
(
"$Id: socket.c,v 1.
49
2000/07/
07 13:58:29 gr
ubb
a
Exp $"
);
RCSID
(
"$Id: socket.c,v 1.
50
2000/07/
29 19:22:18 h
ubb
e
Exp $"
);
#ifdef HAVE_SYS_TYPE_H
#ifdef HAVE_SYS_TYPE_H
#include
<sys/types.h>
#include
<sys/types.h>
...
@@ -96,14 +98,14 @@ static void port_set_id(INT32 args)
...
@@ -96,14 +98,14 @@ static void port_set_id(INT32 args)
if
(
args
<
1
)
if
(
args
<
1
)
error
(
"Too few arguments to port->set_id()
\n
"
);
error
(
"Too few arguments to port->set_id()
\n
"
);
assign_svalue
(
&
THIS
->
id
,
sp
-
args
);
assign_svalue
(
&
THIS
->
id
,
Pike_
sp
-
args
);
pop_n_elems
(
args
-
1
);
pop_n_elems
(
args
-
1
);
}
}
static
void
port_query_id
(
INT32
args
)
static
void
port_query_id
(
INT32
args
)
{
{
pop_n_elems
(
args
);
pop_n_elems
(
args
);
assign_svalue_no_free
(
sp
++
,
&
THIS
->
id
);
assign_svalue_no_free
(
Pike_
sp
++
,
&
THIS
->
id
);
}
}
static
void
port_errno
(
INT32
args
)
static
void
port_errno
(
INT32
args
)
...
@@ -123,7 +125,7 @@ static void port_accept_callback(int fd,void *data)
...
@@ -123,7 +125,7 @@ static void port_accept_callback(int fd,void *data)
#endif
#endif
#endif
#endif
assign_svalue_no_free
(
sp
++
,
&
f
->
id
);
assign_svalue_no_free
(
Pike_
sp
++
,
&
f
->
id
);
apply_svalue
(
&
f
->
accept_callback
,
1
);
apply_svalue
(
&
f
->
accept_callback
,
1
);
pop_stack
();
pop_stack
();
return
;
return
;
...
@@ -137,10 +139,10 @@ static void port_listen_fd(INT32 args)
...
@@ -137,10 +139,10 @@ static void port_listen_fd(INT32 args)
if
(
args
<
1
)
if
(
args
<
1
)
error
(
"Too few arguments to port->bind_fd()
\n
"
);
error
(
"Too few arguments to port->bind_fd()
\n
"
);
if
(
sp
[
-
args
].
type
!=
T_INT
)
if
(
Pike_
sp
[
-
args
].
type
!=
PIKE_
T_INT
)
error
(
"Bad argument 1 to port->bind_fd()
\n
"
);
error
(
"Bad argument 1 to port->bind_fd()
\n
"
);
fd
=
sp
[
-
args
].
u
.
integer
;
fd
=
Pike_
sp
[
-
args
].
u
.
integer
;
if
(
fd
<
0
)
if
(
fd
<
0
)
{
{
...
@@ -160,7 +162,7 @@ static void port_listen_fd(INT32 args)
...
@@ -160,7 +162,7 @@ static void port_listen_fd(INT32 args)
if
(
args
>
1
)
if
(
args
>
1
)
{
{
assign_svalue
(
&
THIS
->
accept_callback
,
sp
+
1
-
args
);
assign_svalue
(
&
THIS
->
accept_callback
,
Pike_
sp
+
1
-
args
);
set_nonblocking
(
fd
,
1
);
set_nonblocking
(
fd
,
1
);
if
(
!
IS_ZERO
(
&
THIS
->
accept_callback
))
if
(
!
IS_ZERO
(
&
THIS
->
accept_callback
))
{
{
...
@@ -186,7 +188,7 @@ static void port_bind(INT32 args)
...
@@ -186,7 +188,7 @@ static void port_bind(INT32 args)
if
(
args
<
1
)
if
(
args
<
1
)
error
(
"Too few arguments to port->bind()
\n
"
);
error
(
"Too few arguments to port->bind()
\n
"
);
if
(
sp
[
-
args
].
type
!=
T_INT
)
if
(
Pike_
sp
[
-
args
].
type
!=
PIKE_
T_INT
)
error
(
"Bad argument 1 to port->bind()
\n
"
);
error
(
"Bad argument 1 to port->bind()
\n
"
);
fd
=
fd_socket
(
AF_INET
,
SOCK_STREAM
,
0
);
fd
=
fd_socket
(
AF_INET
,
SOCK_STREAM
,
0
);
...
@@ -214,14 +216,14 @@ static void port_bind(INT32 args)
...
@@ -214,14 +216,14 @@ static void port_bind(INT32 args)
MEMSET
((
char
*
)
&
addr
,
0
,
sizeof
(
struct
sockaddr_in
));
MEMSET
((
char
*
)
&
addr
,
0
,
sizeof
(
struct
sockaddr_in
));
if
(
args
>
2
&&
sp
[
2
-
args
].
type
==
T_STRING
)
if
(
args
>
2
&&
Pike_
sp
[
2
-
args
].
type
==
PIKE_
T_STRING
)
{
{
get_inet_addr
(
&
addr
,
sp
[
2
-
args
].
u
.
string
->
str
);
get_inet_addr
(
&
addr
,
Pike_
sp
[
2
-
args
].
u
.
string
->
str
);
}
else
{
}
else
{
addr
.
sin_addr
.
s_addr
=
htonl
(
INADDR_ANY
);
addr
.
sin_addr
.
s_addr
=
htonl
(
INADDR_ANY
);
}
}
addr
.
sin_port
=
htons
(
((
u_short
)
sp
[
-
args
].
u
.
integer
)
);
addr
.
sin_port
=
htons
(
((
u_short
)
Pike_
sp
[
-
args
].
u
.
integer
)
);
addr
.
sin_family
=
AF_INET
;
addr
.
sin_family
=
AF_INET
;
THREADS_ALLOW_UID
();
THREADS_ALLOW_UID
();
...
@@ -240,7 +242,7 @@ static void port_bind(INT32 args)
...
@@ -240,7 +242,7 @@ static void port_bind(INT32 args)
if
(
args
>
1
)
if
(
args
>
1
)
{
{
assign_svalue
(
&
THIS
->
accept_callback
,
sp
+
1
-
args
);
assign_svalue
(
&
THIS
->
accept_callback
,
Pike_
sp
+
1
-
args
);
if
(
!
IS_ZERO
(
&
THIS
->
accept_callback
))
if
(
!
IS_ZERO
(
&
THIS
->
accept_callback
))
{
{
add_ref
(
Pike_fp
->
current_object
);
add_ref
(
Pike_fp
->
current_object
);
...
@@ -259,15 +261,15 @@ static void port_create(INT32 args)
...
@@ -259,15 +261,15 @@ static void port_create(INT32 args)
{
{
if
(
args
)
if
(
args
)
{
{
if
(
sp
[
-
args
].
type
==
T_INT
)
if
(
Pike_
sp
[
-
args
].
type
==
PIKE_
T_INT
)
{
{
port_bind
(
args
);
port_bind
(
args
);
return
;
return
;
}
else
{
}
else
{
if
(
sp
[
-
args
].
type
!=
T_STRING
)
if
(
Pike_
sp
[
-
args
].
type
!=
PIKE_
T_STRING
)
error
(
"Bad argument 1 to port->create()
\n
"
);
error
(
"Bad argument 1 to port->create()
\n
"
);
if
(
strcmp
(
"stdin"
,
sp
[
-
args
].
u
.
string
->
str
))
if
(
strcmp
(
"stdin"
,
Pike_
sp
[
-
args
].
u
.
string
->
str
))
error
(
"port->create() called with string other than 'stdin'
\n
"
);
error
(
"port->create() called with string other than 'stdin'
\n
"
);
do_close
(
THIS
,
Pike_fp
->
current_object
);
do_close
(
THIS
,
Pike_fp
->
current_object
);
...
@@ -279,7 +281,7 @@ static void port_create(INT32 args)
...
@@ -279,7 +281,7 @@ static void port_create(INT32 args)
}
else
{
}
else
{
if
(
args
>
1
)
if
(
args
>
1
)
{
{
assign_svalue
(
&
THIS
->
accept_callback
,
sp
+
1
-
args
);
assign_svalue
(
&
THIS
->
accept_callback
,
Pike_
sp
+
1
-
args
);
if
(
!
IS_ZERO
(
&
THIS
->
accept_callback
))
if
(
!
IS_ZERO
(
&
THIS
->
accept_callback
))
{
{
add_ref
(
Pike_fp
->
current_object
);
add_ref
(
Pike_fp
->
current_object
);
...
@@ -358,12 +360,12 @@ static void socket_query_address(INT32 args)
...
@@ -358,12 +360,12 @@ static void socket_query_address(INT32 args)
static
void
init_port_struct
(
struct
object
*
o
)
static
void
init_port_struct
(
struct
object
*
o
)
{
{
THIS
->
fd
=-
1
;
THIS
->
fd
=-
1
;
THIS
->
id
.
type
=
T_INT
;
THIS
->
id
.
type
=
PIKE_
T_INT
;
#ifdef __CHECKER__
#ifdef __CHECKER__
THIS
->
id
.
subtype
=
0
;
THIS
->
id
.
subtype
=
0
;
#endif
#endif
THIS
->
id
.
u
.
integer
=
0
;
THIS
->
id
.
u
.
integer
=
0
;
THIS
->
accept_callback
.
type
=
T_INT
;
THIS
->
accept_callback
.
type
=
PIKE_
T_INT
;
THIS
->
my_errno
=
0
;
THIS
->
my_errno
=
0
;
}
}
...
@@ -372,8 +374,8 @@ static void exit_port_struct(struct object *o)
...
@@ -372,8 +374,8 @@ static void exit_port_struct(struct object *o)
do_close
(
THIS
,
o
);
do_close
(
THIS
,
o
);
free_svalue
(
&
THIS
->
id
);
free_svalue
(
&
THIS
->
id
);
free_svalue
(
&
THIS
->
accept_callback
);
free_svalue
(
&
THIS
->
accept_callback
);
THIS
->
id
.
type
=
T_INT
;
THIS
->
id
.
type
=
PIKE_
T_INT
;
THIS
->
accept_callback
.
type
=
T_INT
;
THIS
->
accept_callback
.
type
=
PIKE_
T_INT
;
}
}
struct
program
*
port_program
;
struct
program
*
port_program
;
...
@@ -388,8 +390,8 @@ void port_setup_program(void)
...
@@ -388,8 +390,8 @@ void port_setup_program(void)
INT32
offset
;
INT32
offset
;
start_new_program
();
start_new_program
();
offset
=
ADD_STORAGE
(
struct
port
);
offset
=
ADD_STORAGE
(
struct
port
);
map_variable
(
"_accept_callback"
,
"mixed"
,
0
,
offset
+
OFFSETOF
(
port
,
accept_callback
),
T_MIXED
);
map_variable
(
"_accept_callback"
,
"mixed"
,
0
,
offset
+
OFFSETOF
(
port
,
accept_callback
),
PIKE_
T_MIXED
);
map_variable
(
"_id"
,
"mixed"
,
0
,
offset
+
OFFSETOF
(
port
,
id
),
T_MIXED
);
map_variable
(
"_id"
,
"mixed"
,
0
,
offset
+
OFFSETOF
(
port
,
id
),
PIKE_
T_MIXED
);
/* function(int,void|mixed,void|string:int) */
/* function(int,void|mixed,void|string:int) */
ADD_FUNCTION
(
"bind"
,
port_bind
,
tFunc
(
tInt
tOr
(
tVoid
,
tMix
)
tOr
(
tVoid
,
tStr
),
tInt
),
0
);
ADD_FUNCTION
(
"bind"
,
port_bind
,
tFunc
(
tInt
tOr
(
tVoid
,
tMix
)
tOr
(
tVoid
,
tStr
),
tInt
),
0
);
/* function(int,void|mixed:int) */
/* function(int,void|mixed:int) */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment