Skip to content

Commit

Permalink
RTSP: convert protocol-specific checks to generic
Browse files Browse the repository at this point in the history
Add a 'readwrite' function to the protocol handler struct and use that
for the extra readwrite functionality RTSP needs.
  • Loading branch information
bagder committed May 5, 2011
1 parent e34131d commit f0612f1
Show file tree
Hide file tree
Showing 18 changed files with 67 additions and 35 deletions.
7 changes: 7 additions & 0 deletions lib/curl_rtmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const struct Curl_handler Curl_handler_rtmp = {
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
rtmp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_RTMP, /* defport */
CURLPROTO_RTMP, /* protocol */
PROTOPT_NONE /* flags*/
Expand All @@ -91,6 +92,7 @@ const struct Curl_handler Curl_handler_rtmpt = {
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
rtmp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_RTMPT, /* defport */
CURLPROTO_RTMPT, /* protocol */
PROTOPT_NONE /* flags*/
Expand All @@ -109,6 +111,7 @@ const struct Curl_handler Curl_handler_rtmpe = {
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
rtmp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_RTMP, /* defport */
CURLPROTO_RTMPE, /* protocol */
PROTOPT_NONE /* flags*/
Expand All @@ -127,6 +130,7 @@ const struct Curl_handler Curl_handler_rtmpte = {
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
rtmp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_RTMPT, /* defport */
CURLPROTO_RTMPTE, /* protocol */
PROTOPT_NONE /* flags*/
Expand All @@ -145,10 +149,12 @@ const struct Curl_handler Curl_handler_rtmps = {
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
rtmp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_RTMPS, /* defport */
CURLPROTO_RTMPS, /* protocol */
PROTOPT_NONE /* flags*/
};

const struct Curl_handler Curl_handler_rtmpts = {
"RTMPTS", /* scheme */
rtmp_setup, /* setup_connection */
Expand All @@ -162,6 +168,7 @@ const struct Curl_handler Curl_handler_rtmpts = {
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
rtmp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_RTMPS, /* defport */
CURLPROTO_RTMPTS, /* protocol */
PROTOPT_NONE /* flags*/
Expand Down
1 change: 1 addition & 0 deletions lib/dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const struct Curl_handler Curl_handler_dict = {
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_DICT, /* defport */
CURLPROTO_DICT, /* protocol */
PROTOPT_NONE /* flags */
Expand Down
1 change: 1 addition & 0 deletions lib/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ const struct Curl_handler Curl_handler_file = {
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
0, /* defport */
CURLPROTO_FILE, /* protocol */
PROTOPT_NONETWORK /* flags */
Expand Down
4 changes: 4 additions & 0 deletions lib/ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ const struct Curl_handler Curl_handler_ftp = {
ftp_getsock, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
ftp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_FTP, /* defport */
CURLPROTO_FTP, /* protocol */
PROTOPT_DUAL | PROTOPT_CLOSEACTION /* flags */
Expand All @@ -202,6 +203,7 @@ const struct Curl_handler Curl_handler_ftps = {
ftp_getsock, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
ftp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_FTPS, /* defport */
CURLPROTO_FTP | CURLPROTO_FTPS, /* protocol */
PROTOPT_SSL | PROTOPT_DUAL | PROTOPT_CLOSEACTION /* flags */
Expand All @@ -226,6 +228,7 @@ static const struct Curl_handler Curl_handler_ftp_proxy = {
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_FTP, /* defport */
CURLPROTO_HTTP, /* protocol */
PROTOPT_NONE /* flags */
Expand All @@ -250,6 +253,7 @@ static const struct Curl_handler Curl_handler_ftps_proxy = {
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_FTPS, /* defport */
CURLPROTO_HTTP, /* protocol */
PROTOPT_NONE /* flags */
Expand Down
1 change: 1 addition & 0 deletions lib/gopher.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const struct Curl_handler Curl_handler_gopher = {
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_GOPHER, /* defport */
CURLPROTO_GOPHER, /* protocol */
PROTOPT_NONE /* flags */
Expand Down
2 changes: 2 additions & 0 deletions lib/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ const struct Curl_handler Curl_handler_http = {
http_getsock_do, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_HTTP, /* defport */
CURLPROTO_HTTP, /* protocol */
PROTOPT_NONE /* flags */
Expand All @@ -161,6 +162,7 @@ const struct Curl_handler Curl_handler_https = {
http_getsock_do, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_HTTPS, /* defport */
CURLPROTO_HTTP | CURLPROTO_HTTPS, /* protocol */
PROTOPT_SSL /* flags */
Expand Down
4 changes: 4 additions & 0 deletions lib/imap.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ const struct Curl_handler Curl_handler_imap = {
imap_getsock, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
imap_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_IMAP, /* defport */
CURLPROTO_IMAP, /* protocol */
PROTOPT_CLOSEACTION /* flags */
Expand All @@ -150,6 +151,7 @@ const struct Curl_handler Curl_handler_imaps = {
imap_getsock, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
imap_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_IMAPS, /* defport */
CURLPROTO_IMAP | CURLPROTO_IMAPS, /* protocol */
PROTOPT_CLOSEACTION | PROTOPT_SSL /* flags */
Expand All @@ -174,6 +176,7 @@ static const struct Curl_handler Curl_handler_imap_proxy = {
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_IMAP, /* defport */
CURLPROTO_HTTP, /* protocol */
PROTOPT_NONE /* flags */
Expand All @@ -198,6 +201,7 @@ static const struct Curl_handler Curl_handler_imaps_proxy = {
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_IMAPS, /* defport */
CURLPROTO_HTTP, /* protocol */
PROTOPT_NONE /* flags */
Expand Down
2 changes: 2 additions & 0 deletions lib/openldap.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const struct Curl_handler Curl_handler_ldap = {
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
ldap_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_LDAP, /* defport */
CURLPROTO_LDAP, /* protocol */
PROTOPT_NONE /* flags */
Expand All @@ -108,6 +109,7 @@ const struct Curl_handler Curl_handler_ldaps = {
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
ldap_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_LDAPS, /* defport */
CURLPROTO_LDAP, /* protocol */
PROTOPT_SSL /* flags */
Expand Down
4 changes: 4 additions & 0 deletions lib/pop3.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ const struct Curl_handler Curl_handler_pop3 = {
pop3_getsock, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
pop3_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_POP3, /* defport */
CURLPROTO_POP3, /* protocol */
PROTOPT_CLOSEACTION /* flags */
Expand All @@ -150,6 +151,7 @@ const struct Curl_handler Curl_handler_pop3s = {
pop3_getsock, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
pop3_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_POP3S, /* defport */
CURLPROTO_POP3 | CURLPROTO_POP3S, /* protocol */
PROTOPT_CLOSEACTION | PROTOPT_SSL /* flags */
Expand All @@ -174,6 +176,7 @@ static const struct Curl_handler Curl_handler_pop3_proxy = {
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_POP3, /* defport */
CURLPROTO_HTTP, /* protocol */
PROTOPT_NONE /* flags */
Expand All @@ -198,6 +201,7 @@ static const struct Curl_handler Curl_handler_pop3s_proxy = {
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_POP3S, /* defport */
CURLPROTO_HTTP, /* protocol */
PROTOPT_NONE /* flags */
Expand Down
23 changes: 19 additions & 4 deletions lib/rtsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ static int rtsp_getsock_do(struct connectdata *conn,
curl_socket_t *socks,
int numsocks);

/*
* Parse and write out any available RTP data.
*
* nread: amount of data left after k->str. will be modified if RTP
* data is parsed and k->str is moved up
* readmore: whether or not the RTP parser needs more data right away
*/
static CURLcode rtsp_rtp_readwrite(struct SessionHandle *data,
struct connectdata *conn,
ssize_t *nread,
bool *readmore);


/* this returns the socket to wait for in the DO and DOING state for the multi
interface and then we're always _sending_ a request and thus we wait for
the single socket to become writable only */
Expand Down Expand Up @@ -96,6 +109,7 @@ const struct Curl_handler Curl_handler_rtsp = {
rtsp_getsock_do, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
Curl_rtsp_disconnect, /* disconnect */
rtsp_rtp_readwrite, /* readwrite */
PORT_RTSP, /* defport */
CURLPROTO_RTSP, /* protocol */
PROTOPT_NONE /* flags */
Expand Down Expand Up @@ -560,10 +574,11 @@ CURLcode Curl_rtsp(struct connectdata *conn, bool *done)
return result;
}

CURLcode Curl_rtsp_rtp_readwrite(struct SessionHandle *data,
struct connectdata *conn,
ssize_t *nread,
bool *readmore) {

static CURLcode rtsp_rtp_readwrite(struct SessionHandle *data,
struct connectdata *conn,
ssize_t *nread,
bool *readmore) {
struct SingleRequest *k = &data->req;
struct rtsp_conn *rtspc = &(conn->proto.rtspc);

Expand Down
13 changes: 0 additions & 13 deletions lib/rtsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@

extern const struct Curl_handler Curl_handler_rtsp;

/*
* Parse and write out any available RTP data.
*
* nread: amount of data left after k->str. will be modified if RTP
* data is parsed and k->str is moved up
* readmore: whether or not the RTP parser needs more data right away
*/
CURLcode Curl_rtsp_rtp_readwrite(struct SessionHandle *data,
struct connectdata *conn,
ssize_t *nread,
bool *readmore);


/* protocol-specific functions set up to be called by the main engine */
CURLcode Curl_rtsp(struct connectdata *conn, bool *done);
CURLcode Curl_rtsp_done(struct connectdata *conn, CURLcode, bool premature);
Expand Down
4 changes: 4 additions & 0 deletions lib/smtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const struct Curl_handler Curl_handler_smtp = {
smtp_getsock, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
smtp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_SMTP, /* defport */
CURLPROTO_SMTP, /* protocol */
PROTOPT_CLOSEACTION /* flags */
Expand All @@ -158,6 +159,7 @@ const struct Curl_handler Curl_handler_smtps = {
smtp_getsock, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
smtp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_SMTPS, /* defport */
CURLPROTO_SMTP | CURLPROTO_SMTPS, /* protocol */
PROTOPT_CLOSEACTION | PROTOPT_SSL /* flags */
Expand All @@ -182,6 +184,7 @@ static const struct Curl_handler Curl_handler_smtp_proxy = {
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_SMTP, /* defport */
CURLPROTO_HTTP, /* protocol */
PROTOPT_NONE /* flags */
Expand All @@ -206,6 +209,7 @@ static const struct Curl_handler Curl_handler_smtps_proxy = {
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_SMTPS, /* defport */
CURLPROTO_HTTP, /* protocol */
PROTOPT_NONE /* flags */
Expand Down
2 changes: 2 additions & 0 deletions lib/ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ const struct Curl_handler Curl_handler_scp = {
ssh_getsock, /* doing_getsock */
ssh_perform_getsock, /* perform_getsock */
scp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_SSH, /* defport */
CURLPROTO_SCP, /* protocol */
PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION /* flags */
Expand All @@ -195,6 +196,7 @@ const struct Curl_handler Curl_handler_sftp = {
ssh_getsock, /* doing_getsock */
ssh_perform_getsock, /* perform_getsock */
sftp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_SSH, /* defport */
CURLPROTO_SFTP, /* protocol */
PROTOPT_DIRLOCK | PROTOPT_CLOSEACTION /* flags */
Expand Down
1 change: 1 addition & 0 deletions lib/telnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ const struct Curl_handler Curl_handler_telnet = {
ZERO_NULL, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
ZERO_NULL, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_TELNET, /* defport */
CURLPROTO_TELNET, /* protocol */
PROTOPT_NONE /* flags */
Expand Down
1 change: 1 addition & 0 deletions lib/tftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ const struct Curl_handler Curl_handler_tftp = {
tftp_getsock, /* doing_getsock */
ZERO_NULL, /* perform_getsock */
tftp_disconnect, /* disconnect */
ZERO_NULL, /* readwrite */
PORT_TFTP, /* defport */
CURLPROTO_TFTP, /* protocol */
PROTOPT_NONE /* flags */
Expand Down
Loading

0 comments on commit f0612f1

Please sign in to comment.