Revision f3bfe388

View differences:

ffserver.c
2978 2978
    struct sockaddr_in my_addr;
2979 2979

  
2980 2980
    /* find which url is asked */
2981
    ff_url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url);
2981
    av_url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url);
2982 2982
    path = path1;
2983 2983
    if (*path == '/')
2984 2984
        path++;
......
3055 3055
    RTSPActionServerSetup setup;
3056 3056

  
3057 3057
    /* find which url is asked */
3058
    ff_url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url);
3058
    av_url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url);
3059 3059
    path = path1;
3060 3060
    if (*path == '/')
3061 3061
        path++;
......
3198 3198
        return NULL;
3199 3199

  
3200 3200
    /* find which url is asked */
3201
    ff_url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url);
3201
    av_url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url);
3202 3202
    path = path1;
3203 3203
    if (*path == '/')
3204 3204
        path++;
libavformat/avformat.h
1185 1185
int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap);
1186 1186

  
1187 1187
/**
1188
 * Split a URL string into components.
1189
 *
1190
 * The pointers to buffers for storing individual components may be null,
1191
 * in order to ignore that component. Buffers for components not found are
1192
 * set to empty strings. If the port is not found, it is set to a negative
1193
 * value.
1194
 *
1195
 * @param proto the buffer for the protocol
1196
 * @param proto_size the size of the proto buffer
1197
 * @param authorization the buffer for the authorization
1198
 * @param authorization_size the size of the authorization buffer
1199
 * @param hostname the buffer for the host name
1200
 * @param hostname_size the size of the hostname buffer
1201
 * @param port_ptr a pointer to store the port number in
1202
 * @param path the buffer for the path
1203
 * @param path_size the size of the path buffer
1204
 * @param url the URL to split
1205
 */
1206
void av_url_split(char *proto,         int proto_size,
1207
                  char *authorization, int authorization_size,
1208
                  char *hostname,      int hostname_size,
1209
                  int *port_ptr,
1210
                  char *path,          int path_size,
1211
                  const char *url);
1212

  
1213
/**
1188 1214
 * Allocates the stream private data and writes the stream header to an
1189 1215
 * output media file.
1190 1216
 *
libavformat/gopher.c
90 90
    h->priv_data = s;
91 91

  
92 92
    /* needed in any case to build the host string */
93
    ff_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
93
    av_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
94 94
                 path, sizeof(path), uri);
95 95

  
96 96
    if (port < 0)
libavformat/http.c
105 105
    /* fill the dest addr */
106 106
 redo:
107 107
    /* needed in any case to build the host string */
108
    ff_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
108
    av_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
109 109
                 path1, sizeof(path1), s->location);
110 110
    ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL);
111 111

  
112 112
    if (use_proxy) {
113
        ff_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
113
        av_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
114 114
                     NULL, 0, proxy_path);
115 115
        path = s->location;
116 116
    } else {
libavformat/internal.h
89 89
                          const char *filename, void *logctx,
90 90
                          unsigned int offset, unsigned int max_probe_size);
91 91

  
92
#if LIBAVFORMAT_VERSION_MAJOR < 53
92 93
/**
93
 * Splits a URL string into components. To reassemble components back into
94
 * a URL, use ff_url_join instead of using snprintf directly.
95
 *
96
 * The pointers to buffers for storing individual components may be null,
97
 * in order to ignore that component. Buffers for components not found are
98
 * set to empty strings. If the port isn't found, it is set to a negative
99
 * value.
100
 *
101
 * @see ff_url_join
102
 *
103
 * @param proto the buffer for the protocol
104
 * @param proto_size the size of the proto buffer
105
 * @param authorization the buffer for the authorization
106
 * @param authorization_size the size of the authorization buffer
107
 * @param hostname the buffer for the host name
108
 * @param hostname_size the size of the hostname buffer
109
 * @param port_ptr a pointer to store the port number in
110
 * @param path the buffer for the path
111
 * @param path_size the size of the path buffer
112
 * @param url the URL to split
94
 * @deprecated use av_url_split() instead
113 95
 */
114 96
void ff_url_split(char *proto, int proto_size,
115 97
                  char *authorization, int authorization_size,
......
117 99
                  int *port_ptr,
118 100
                  char *path, int path_size,
119 101
                  const char *url);
102
#endif
120 103

  
121 104
/**
122 105
 * Assembles a URL string from components. This is the reverse operation
123
 * of ff_url_split.
106
 * of av_url_split.
124 107
 *
125 108
 * Note, this requires networking to be initialized, so the caller must
126 109
 * ensure ff_network_init has been called.
127 110
 *
128
 * @see ff_url_split
111
 * @see av_url_split
129 112
 *
130 113
 * @param str the buffer to fill with the url
131 114
 * @param size the size of the str buffer
libavformat/mmst.c
581 581
        return AVERROR(ENOMEM);
582 582

  
583 583
    // only for MMS over TCP, so set proto = NULL
584
    ff_url_split(NULL, 0, NULL, 0,
584
    av_url_split(NULL, 0, NULL, 0,
585 585
            mms->host, sizeof(mms->host), &port, mms->path,
586 586
            sizeof(mms->path), uri);
587 587

  
libavformat/rtmpproto.c
813 813
    s->priv_data = rt;
814 814
    rt->is_input = !(flags & URL_WRONLY);
815 815

  
816
    ff_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname), &port,
816
    av_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname), &port,
817 817
                 path, sizeof(path), s->filename);
818 818

  
819 819
    if (port < 0)
libavformat/rtpproto.c
66 66
    char buf[1024];
67 67
    char path[1024];
68 68

  
69
    ff_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port,
69
    av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port,
70 70
                 path, sizeof(path), uri);
71 71

  
72 72
    ff_url_join(buf, sizeof(buf), "udp", NULL, hostname, port, "%s", path);
......
146 146
        return AVERROR(ENOMEM);
147 147
    h->priv_data = s;
148 148

  
149
    ff_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &rtp_port,
149
    av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &rtp_port,
150 150
                 path, sizeof(path), uri);
151 151
    /* extract parameters */
152 152
    ttl = -1;
libavformat/rtsp.c
327 327
            rtsp_st = st->priv_data;
328 328

  
329 329
            /* XXX: may need to add full url resolution */
330
            ff_url_split(proto, sizeof(proto), NULL, 0, NULL, 0,
330
            av_url_split(proto, sizeof(proto), NULL, 0, NULL, 0,
331 331
                         NULL, NULL, 0, p);
332 332
            if (proto[0] == '\0') {
333 333
                /* relative control URL */
......
1366 1366
redirect:
1367 1367
    rt->control_transport = RTSP_MODE_PLAIN;
1368 1368
    /* extract hostname and port */
1369
    ff_url_split(NULL, 0, auth, sizeof(auth),
1369
    av_url_split(NULL, 0, auth, sizeof(auth),
1370 1370
                 host, sizeof(host), &port, path, sizeof(path), s->filename);
1371 1371
    if (*auth) {
1372 1372
        av_strlcpy(rt->auth, auth, sizeof(rt->auth));
libavformat/sdp.c
109 109
    const char *p;
110 110
    char proto[32];
111 111

  
112
    ff_url_split(proto, sizeof(proto), NULL, 0, dest_addr, size, &port, NULL, 0, url);
112
    av_url_split(proto, sizeof(proto), NULL, 0, dest_addr, size, &port, NULL, 0, url);
113 113

  
114 114
    *ttl = 0;
115 115

  
libavformat/tcp.c
45 45
    char hostname[1024],proto[1024],path[1024];
46 46
    char portstr[10];
47 47

  
48
    ff_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname),
48
    av_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname),
49 49
        &port, path, sizeof(path), uri);
50 50
    if (strcmp(proto,"tcp") || port <= 0 || port >= 65536)
51 51
        return AVERROR(EINVAL);
libavformat/udp.c
266 266
    char hostname[256];
267 267
    int port;
268 268

  
269
    ff_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);
269
    av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);
270 270

  
271 271
    /* set the destination address */
272 272
    s->dest_addr_len = udp_set_url(&s->dest_addr, hostname, port);
......
347 347
    }
348 348

  
349 349
    /* fill the dest addr */
350
    ff_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);
350
    av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);
351 351

  
352
    /* XXX: fix ff_url_split */
352
    /* XXX: fix av_url_split */
353 353
    if (hostname[0] == '\0' || hostname[0] == '?') {
354 354
        /* only accepts null hostname if input */
355 355
        if (flags & URL_WRONLY)
libavformat/utils.c
3493 3493
    pkt_dump_internal(avcl, NULL, level, pkt, dump_payload);
3494 3494
}
3495 3495

  
3496
#if LIBAVFORMAT_VERSION_MAJOR < 53
3497
attribute_deprecated
3496 3498
void ff_url_split(char *proto, int proto_size,
3497 3499
                  char *authorization, int authorization_size,
3498 3500
                  char *hostname, int hostname_size,
......
3500 3502
                  char *path, int path_size,
3501 3503
                  const char *url)
3502 3504
{
3505
    av_url_split(proto, proto_size,
3506
                 authorization, authorization_size,
3507
                 hostname, hostname_size,
3508
                 port_ptr,
3509
                 path, path_size,
3510
                 url);
3511
}
3512
#endif
3513

  
3514
void av_url_split(char *proto, int proto_size,
3515
                  char *authorization, int authorization_size,
3516
                  char *hostname, int hostname_size,
3517
                  int *port_ptr,
3518
                  char *path, int path_size,
3519
                  const char *url)
3520
{
3503 3521
    const char *p, *ls, *at, *col, *brk;
3504 3522

  
3505 3523
    if (port_ptr)               *port_ptr = -1;

Also available in: Unified diff