lib570.c
Go to the documentation of this file.
1 /***************************************************************************
2  * _ _ ____ _
3  * Project ___| | | | _ \| |
4  * / __| | | | |_) | |
5  * | (__| |_| | _ <| |___
6  * \___|\___/|_| \_\_____|
7  *
8  * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
9  *
10  * This software is licensed as described in the file COPYING, which
11  * you should have received as part of this distribution. The terms
12  * are also available at https://curl.haxx.se/docs/copyright.html.
13  *
14  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15  * copies of the Software, and permit persons to whom the Software is
16  * furnished to do so, under the terms of the COPYING file.
17  *
18  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19  * KIND, either express or implied.
20  *
21  ***************************************************************************/
22 #include "test.h"
23 #include "memdebug.h"
24 
25 /* build request url */
26 static char *suburl(const char *base, int i)
27 {
28  return curl_maprintf("%s%.4d", base, i);
29 }
30 
31 int test(char *URL)
32 {
33  int res;
34  CURL *curl;
35  int request = 1;
36  char *stream_uri = NULL;
37 
39  fprintf(stderr, "curl_global_init() failed\n");
40  return TEST_ERR_MAJOR_BAD;
41  }
42 
43  curl = curl_easy_init();
44  if(!curl) {
45  fprintf(stderr, "curl_easy_init() failed\n");
47  return TEST_ERR_MAJOR_BAD;
48  }
49 
50  test_setopt(curl, CURLOPT_HEADERDATA, stdout);
51  test_setopt(curl, CURLOPT_WRITEDATA, stdout);
52  test_setopt(curl, CURLOPT_VERBOSE, 1L);
53 
54  test_setopt(curl, CURLOPT_URL, URL);
55 
56  test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_OPTIONS);
57 
58  stream_uri = suburl(URL, request++);
59  if(!stream_uri) {
60  res = TEST_ERR_MAJOR_BAD;
61  goto test_cleanup;
62  }
63  test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
64  free(stream_uri);
65  stream_uri = NULL;
66 
67  res = curl_easy_perform(curl);
68  if(res != (int)CURLE_RTSP_CSEQ_ERROR) {
69  fprintf(stderr, "Failed to detect CSeq mismatch");
70  res = TEST_ERR_MAJOR_BAD;
71  goto test_cleanup;
72  }
73 
74  test_setopt(curl, CURLOPT_RTSP_CLIENT_CSEQ, 999L);
75  test_setopt(curl, CURLOPT_RTSP_TRANSPORT,
76  "RAW/RAW/UDP;unicast;client_port=3056-3057");
77  test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP);
78 
79  stream_uri = suburl(URL, request++);
80  if(!stream_uri) {
81  res = TEST_ERR_MAJOR_BAD;
82  goto test_cleanup;
83  }
84  test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
85  free(stream_uri);
86  stream_uri = NULL;
87 
88  res = curl_easy_perform(curl);
89  if(res)
90  goto test_cleanup;
91 
92  test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_PLAY);
93 
94  stream_uri = suburl(URL, request++);
95  if(!stream_uri) {
96  res = TEST_ERR_MAJOR_BAD;
97  goto test_cleanup;
98  }
99  test_setopt(curl, CURLOPT_RTSP_STREAM_URI, stream_uri);
100  free(stream_uri);
101  stream_uri = NULL;
102 
103  res = curl_easy_perform(curl);
104  if(res != CURLE_RTSP_SESSION_ERROR) {
105  fprintf(stderr, "Failed to detect a Session ID mismatch");
106  }
107 
108 test_cleanup:
109  free(stream_uri);
110 
111  curl_easy_cleanup(curl);
113 
114  return res;
115 }
116 
#define free(ptr)
Definition: curl_memory.h:130
#define test_setopt(A, B, C)
Definition: test.h:47
auto base
static int res
static char * suburl(const char *base, int i)
Definition: lib570.c:26
unsigned int i
Definition: unit1303.c:79
#define TEST_ERR_MAJOR_BAD
Definition: test.h:85
CURL_EXTERN CURL * curl_easy_init(void)
Definition: easy.c:343
int test(char *URL)
Definition: lib570.c:31
CURL_EXTERN void curl_easy_cleanup(CURL *curl)
Definition: curl.h:455
CURL_EXTERN CURLcode curl_global_init(long flags)
curl_global_init() globally initializes curl given a bitwise set of the different features of what to...
Definition: easy.c:271
void CURL
Definition: curl.h:102
#define fprintf
Definition: curl_printf.h:41
CURL_EXTERN void curl_global_cleanup(void)
curl_global_cleanup() globally cleanups curl, uses the value of "init_flags" to determine what needs ...
Definition: easy.c:312
#define CURL_GLOBAL_ALL
Definition: curl.h:2519
CURL_EXTERN char * curl_maprintf(const char *format,...)
Definition: mprintf.c:1066
static CURL * curl
Definition: sessioninfo.c:35
CURL_EXTERN CURLcode curl_easy_perform(CURL *curl)


rc_tagdetect_client
Author(s): Monika Florek-Jasinska , Raphael Schaller
autogenerated on Sat Feb 13 2021 03:42:15