Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Wynn
purr-data
Commits
acf61ca0
Commit
acf61ca0
authored
Jul 02, 2008
by
Miller Puckette
Browse files
Max/MSP fixes to bonk~ and sigmund~
parent
e609134d
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
extra/bonk~/bonk~.c
View file @
acf61ca0
...
...
@@ -198,8 +198,6 @@ typedef struct _bonk
void
*
obex
;
void
*
x_cookedout
;
void
*
x_clock
;
short
x_vol
;
#endif
/* MSP */
/* parameters */
int
x_npoints
;
/* number of points in input buffer */
...
...
@@ -251,7 +249,6 @@ void bonk_setup(void);
int
main
();
static
void
bonk_thresh
(
t_bonk
*
x
,
t_floatarg
f1
,
t_floatarg
f2
);
static
void
bonk_mask
(
t_bonk
*
x
,
t_floatarg
f1
,
t_floatarg
f2
);
static
void
bonk_print
(
t_bonk
*
x
,
t_floatarg
f
);
static
void
bonk_bang
(
t_bonk
*
x
);
...
...
@@ -1161,7 +1158,7 @@ int main()
t_class
*
c
;
t_object
*
attr
;
long
attrflags
=
0
;
t_symbol
*
sym_long
=
gensym
(
"long"
),
*
sym_float32
=
gensym
(
"float32"
);
t_symbol
*
sym_long
=
gensym
(
"long"
),
*
sym_float32
=
gensym
(
"float32"
);
c
=
class_new
(
"bonk~"
,
(
method
)
bonk_new
,
(
method
)
bonk_free
,
sizeof
(
t_bonk
),
(
method
)
0L
,
A_GIMME
,
0
);
...
...
extra/sigmund~/sigmund~.c
View file @
acf61ca0
This diff is collapsed.
Click to expand it.
src/u_pdreceive.c
View file @
acf61ca0
...
...
@@ -2,10 +2,15 @@
* For information on usage and redistribution, and for a DISCLAIMER OF ALL
* WARRANTIES, see the file, "LICENSE.txt," in the Pd distribution. */
/* the "pdreceive" command.
This is a standalone program that receives messages
/* the "pdreceive" command. This is a standalone program that receives messages
from Pd via the netsend/netreceive ("FUDI") protocol, and copies them to
standard output. */
/* May 2008 : fixed a buffer overflow problem; pdreceive sometimes
repeated infinitely its buffer during high speed transfer.
Moonix::Antoine Rousseau
*/
#include <sys/types.h>
#include <string.h>
#include <stdio.h>
...
...
@@ -26,10 +31,10 @@ standard output. */
typedef
struct
_fdpoll
{
int
fdp_fd
;
char
*
fdp_
in
buf
;
int
fdp_
inhead
;
int
fdp_
intail
;
int
fdp_
udp
;
char
*
fdp_
out
buf
;
/*output message buffer*/
int
fdp_
outlen
;
/*length of output message*/
int
fdp_
discard
;
/*buffer overflow: output message is incomplete, discard it*/
int
fdp_
gotsemi
;
/*last char from input was a semicolon*/
}
t_fdpoll
;
static
int
nfdpoll
;
...
...
@@ -122,8 +127,8 @@ static void addport(int fd)
fp
->
fdp_fd
=
fd
;
nfdpoll
++
;
if
(
fd
>=
maxfd
)
maxfd
=
fd
+
1
;
fp
->
fdp_
inhea
d
=
fp
->
fdp_
intail
=
0
;
if
(
!
(
fp
->
fdp_
in
buf
=
malloc
(
BUFSIZE
)))
fp
->
fdp_
outlen
=
fp
->
fdp_discar
d
=
fp
->
fdp_
gotsemi
=
0
;
if
(
!
(
fp
->
fdp_
out
buf
=
malloc
(
BUFSIZE
)))
{
fprintf
(
stderr
,
"out of memory"
);
exit
(
1
);
...
...
@@ -141,7 +146,7 @@ static void rmport(t_fdpoll *x)
if
(
fp
==
x
)
{
x_closesocket
(
fp
->
fdp_fd
);
free
(
fp
->
fdp_
in
buf
);
free
(
fp
->
fdp_
out
buf
);
while
(
i
--
)
{
fp
[
0
]
=
fp
[
1
];
...
...
@@ -191,75 +196,66 @@ static void udpread(void)
}
}
static
int
tcpmakeoutput
(
t_fdpoll
*
x
)
static
int
tcpmakeoutput
(
t_fdpoll
*
x
,
char
*
inbuf
,
int
len
)
{
char
messbuf
[
BUFSIZE
+
1
],
*
bp
=
messbuf
;
int
indx
;
int
inhead
=
x
->
fdp_inhead
;
int
intail
=
x
->
fdp_intail
;
char
*
inbuf
=
x
->
fdp_inbuf
;
if
(
intail
==
inhead
)
return
(
0
);
for
(
indx
=
intail
;
indx
!=
inhead
;
indx
=
(
indx
+
1
)
&
(
BUFSIZE
-
1
))
int
i
;
int
outlen
=
x
->
fdp_outlen
;
char
*
outbuf
=
x
->
fdp_outbuf
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
char
c
=
inbuf
[
i
];
if
((
c
!=
'\n'
)
||
(
!
x
->
fdp_gotsemi
))
outbuf
[
outlen
++
]
=
c
;
x
->
fdp_gotsemi
=
0
;
if
(
outlen
>=
(
BUFSIZE
-
1
))
/*output buffer overflow; reserve 1 for '\n' */
{
fprintf
(
stderr
,
"pdreceive: message too long; discarding
\n
"
);
outlen
=
0
;
x
->
fdp_discard
=
1
;
}
/* search for a semicolon. */
char
c
=
*
bp
++
=
inbuf
[
indx
];
if
(
c
==
';'
)
{
intail
=
(
indx
+
1
)
&
(
BUFSIZE
-
1
);
if
(
inbuf
[
intail
]
==
'\n'
)
intail
=
(
intail
+
1
)
&
(
BUFSIZE
-
1
);
*
bp
++
=
'\n'
;
#ifdef MSW
outbuf
[
outlen
++
]
=
'\n'
;
if
(
!
x
->
fdp_discard
)
{
int
j
;
for
(
j
=
0
;
j
<
bp
-
messbuf
;
j
++
)
putchar
(
messbuf
[
j
]);
}
#ifdef MSW
{
int
j
;
for
(
j
=
0
;
j
<
bp
-
messbuf
;
j
++
)
putchar
(
messbuf
[
j
]);
}
#else
write
(
1
,
mess
buf
,
bp
-
messbuf
);
write
(
1
,
out
buf
,
outlen
);
#endif
x
->
fdp_inhead
=
inhead
;
x
->
fdp_intail
=
intail
;
return
(
1
);
}
}
}
/* if (!x->fdp_discard) */
outlen
=
0
;
x
->
fdp_discard
=
0
;
x
->
fdp_gotsemi
=
1
;
}
/* if (c == ';') */
}
/* for */
x
->
fdp_outlen
=
outlen
;
return
(
0
);
}
static
void
tcpread
(
t_fdpoll
*
x
)
{
int
readto
=
(
x
->
fdp_inhead
>=
x
->
fdp_intail
?
BUFSIZE
:
x
->
fdp_intail
-
1
);
int
ret
;
int
ret
;
char
inbuf
[
BUFSIZE
];
/* the input buffer might be full. If so, drop the whole thing */
if
(
readto
==
x
->
fdp_inhead
)
{
fprintf
(
stderr
,
"pd: dropped message from gui
\n
"
);
x
->
fdp_inhead
=
x
->
fdp_intail
=
0
;
readto
=
BUFSIZE
;
}
else
ret
=
recv
(
x
->
fdp_fd
,
inbuf
,
BUFSIZE
,
0
);
if
(
ret
<
0
)
{
ret
=
recv
(
x
->
fdp_fd
,
x
->
fdp_inbuf
+
x
->
fdp_inhead
,
readto
-
x
->
fdp_inhead
,
0
);
if
(
ret
<
0
)
{
sockerror
(
"recv (tcp)"
);
rmport
(
x
);
}
else
if
(
ret
==
0
)
rmport
(
x
);
else
{
x
->
fdp_inhead
+=
ret
;
if
(
x
->
fdp_inhead
>=
BUFSIZE
)
x
->
fdp_inhead
=
0
;
while
(
tcpmakeoutput
(
x
))
;
}
sockerror
(
"recv (tcp)"
);
rmport
(
x
);
}
else
if
(
ret
==
0
)
rmport
(
x
);
else
tcpmakeoutput
(
x
,
inbuf
,
ret
);
}
static
void
dopoll
(
void
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment