quvi_new: Add call to bindtextdomain
[libquvi.git] / src / net / resolve.c
blob3554421474402dbc8cafe3108258a37abe046a53
1 /* libquvi
2 * Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301 USA
20 #include "config.h"
22 #include <glib.h>
24 #include "quvi.h"
25 /* -- */
26 #include "_quvi_s.h"
27 #include "_quvi_macro.h"
28 #include "_quvi_net_resolve_s.h"
29 /* -- */
30 #include "net/resolve.h"
31 #include "net/handle.h"
33 extern QuviError c_resolve(_quvi_t, _quvi_net_resolve_t);
35 QuviError n_resolve(_quvi_t q, _quvi_net_resolve_t r)
37 QuviError rc = QUVI_OK;
39 if (q->cb.status != NULL)
41 const glong p = q_makelong(QUVI_CALLBACK_STATUS_RESOLVE, 0);
43 if (q->cb.status(p, 0) != QUVI_OK)
44 return (QUVI_ERROR_CALLBACK_ABORTED);
47 if (q->cb.resolve != NULL)
48 rc = q->cb.resolve(r);
49 else
50 rc = c_resolve(q, r);
52 if (rc == QUVI_OK)
54 if (q->cb.status != NULL)
56 const glong p = q_makelong(QUVI_CALLBACK_STATUS_RESOLVE,
57 QUVI_CALLBACK_STATUS_DONE);
59 if (q->cb.status(p, 0) != QUVI_OK)
60 rc = QUVI_ERROR_CALLBACK_ABORTED;
63 else
65 if (r->status.errmsg->len >0)
66 g_string_assign(q->status.errmsg, r->status.errmsg->str);
67 else
69 g_string_assign(q->status.errmsg,
70 "unknown error: callback returned empty errmsg");
74 q->status.resp_code = r->status.resp_code;
75 q->status.rc = rc;
77 return (rc);
80 /* vim: set ts=2 sw=2 tw=72 expandtab: */