2 * Copyright (C) 2012,2013 Toni Gundogdu <legatvs@gmail.com>
4 * This file is part of libquvi <http://quvi.sourceforge.net/>.
6 * This library is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU Affero General Public
8 * License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General
17 * Public License along with this library. If not, see
18 * <http://www.gnu.org/licenses/>.
29 #include "_quvi_net_s.h"
30 #include "_quvi_net_resolve_s.h"
32 #include "net/handle.h"
35 static GString
*_escaped(const gchar
*url
)
40 /* Pass the URL in escaped form to libcurl. */
41 e
= m_url_escaped_form(url
);
48 gpointer
n_new(_quvi_t q
, const gchar
*url
)
50 _quvi_net_t n
= g_new0(struct _quvi_net_s
, 1);
51 n
->http_metainfo
.content_type
= g_string_new(NULL
);
52 n
->status
.errmsg
= g_string_new(NULL
);
53 n
->fetch
.content
= g_string_new(NULL
);
54 n
->url
.addr
= _escaped(url
);
59 void n_free(gpointer p
)
61 _quvi_net_t n
= (_quvi_net_t
) p
;
66 g_string_free(n
->url
.addr
, TRUE
);
69 g_string_free(n
->status
.errmsg
, TRUE
);
70 n
->status
.errmsg
= NULL
;
72 g_string_free(n
->fetch
.content
, TRUE
);
73 n
->fetch
.content
= NULL
;
75 g_string_free(n
->http_metainfo
.content_type
, TRUE
);
76 n
->http_metainfo
.content_type
= NULL
;
82 gpointer
n_resolve_new(_quvi_t q
, const gchar
*url
)
84 _quvi_net_resolve_t r
= g_new0(struct _quvi_net_resolve_s
, 1);
85 r
->status
.errmsg
= g_string_new(NULL
);
86 r
->url
.dst
= g_string_new(NULL
);
87 r
->url
.addr
= _escaped(url
);
92 void n_resolve_free(gpointer p
)
94 _quvi_net_resolve_t r
= (_quvi_net_resolve_t
) p
;
96 g_string_free(r
->status
.errmsg
, TRUE
);
97 r
->status
.errmsg
= NULL
;
99 g_string_free(r
->url
.addr
, TRUE
);
102 g_string_free(r
->url
.dst
, TRUE
);
109 /* vim: set ts=2 sw=2 tw=72 expandtab: */