mirror of git://git.sysmocom.de/ofono
mbpi: Add filename and line information on error
This commit is contained in:
parent
fda1e1cc71
commit
d24d5219e7
|
@ -73,6 +73,23 @@ void mbpi_provision_data_free(struct ofono_gprs_provision_data *data)
|
||||||
g_free(data);
|
g_free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mbpi_g_set_error(GMarkupParseContext *context, GError **error,
|
||||||
|
GQuark domain, gint code, const gchar *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
gint line_number, char_number;
|
||||||
|
|
||||||
|
g_markup_parse_context_get_position(context, &line_number,
|
||||||
|
&char_number);
|
||||||
|
va_start(ap, fmt);
|
||||||
|
|
||||||
|
*error = g_error_new_valist(domain, code, fmt, ap);
|
||||||
|
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
g_prefix_error(error, "%s:%d ", MBPI_DATABASE, line_number);
|
||||||
|
}
|
||||||
|
|
||||||
static void text_handler(GMarkupParseContext *context,
|
static void text_handler(GMarkupParseContext *context,
|
||||||
const gchar *text, gsize text_len,
|
const gchar *text, gsize text_len,
|
||||||
gpointer userdata, GError **error)
|
gpointer userdata, GError **error)
|
||||||
|
@ -90,7 +107,8 @@ static const GMarkupParser text_parser = {
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void usage_start(const gchar **attribute_names,
|
static void usage_start(GMarkupParseContext *context,
|
||||||
|
const gchar **attribute_names,
|
||||||
const gchar **attribute_values,
|
const gchar **attribute_values,
|
||||||
enum ofono_gprs_context_type *type, GError **error)
|
enum ofono_gprs_context_type *type, GError **error)
|
||||||
{
|
{
|
||||||
|
@ -102,9 +120,9 @@ static void usage_start(const gchar **attribute_names,
|
||||||
text = attribute_values[i];
|
text = attribute_values[i];
|
||||||
|
|
||||||
if (text == NULL) {
|
if (text == NULL) {
|
||||||
g_set_error(error, G_MARKUP_ERROR,
|
mbpi_g_set_error(context, error, G_MARKUP_ERROR,
|
||||||
G_MARKUP_ERROR_MISSING_ATTRIBUTE,
|
G_MARKUP_ERROR_MISSING_ATTRIBUTE,
|
||||||
"Missing attribute: type");
|
"Missing attribute: type");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +133,7 @@ static void usage_start(const gchar **attribute_names,
|
||||||
else if (strcmp(text, "wap") == 0)
|
else if (strcmp(text, "wap") == 0)
|
||||||
*type = OFONO_GPRS_CONTEXT_TYPE_WAP;
|
*type = OFONO_GPRS_CONTEXT_TYPE_WAP;
|
||||||
else
|
else
|
||||||
g_set_error(error, G_MARKUP_ERROR,
|
mbpi_g_set_error(context, error, G_MARKUP_ERROR,
|
||||||
G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
|
G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
|
||||||
"Unknown usage attribute: %s", text);
|
"Unknown usage attribute: %s", text);
|
||||||
}
|
}
|
||||||
|
@ -136,7 +154,7 @@ static void apn_start(GMarkupParseContext *context, const gchar *element_name,
|
||||||
g_markup_parse_context_push(context, &text_parser,
|
g_markup_parse_context_push(context, &text_parser,
|
||||||
&apn->password);
|
&apn->password);
|
||||||
else if (g_str_equal(element_name, "usage"))
|
else if (g_str_equal(element_name, "usage"))
|
||||||
usage_start(attribute_names, attribute_values,
|
usage_start(context, attribute_names, attribute_values,
|
||||||
&apn->type, error);
|
&apn->type, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +194,8 @@ static const GMarkupParser skip_parser = {
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void network_id_handler(struct gsm_data *gsm,
|
static void network_id_handler(GMarkupParseContext *context,
|
||||||
|
struct gsm_data *gsm,
|
||||||
const gchar **attribute_names,
|
const gchar **attribute_names,
|
||||||
const gchar **attribute_values,
|
const gchar **attribute_values,
|
||||||
GError **error)
|
GError **error)
|
||||||
|
@ -192,16 +211,16 @@ static void network_id_handler(struct gsm_data *gsm,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mcc == NULL) {
|
if (mcc == NULL) {
|
||||||
g_set_error(error, G_MARKUP_ERROR,
|
mbpi_g_set_error(context, error, G_MARKUP_ERROR,
|
||||||
G_MARKUP_ERROR_MISSING_ATTRIBUTE,
|
G_MARKUP_ERROR_MISSING_ATTRIBUTE,
|
||||||
"Missing attribute: mcc");
|
"Missing attribute: mcc");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mnc == NULL) {
|
if (mnc == NULL) {
|
||||||
g_set_error(error, G_MARKUP_ERROR,
|
mbpi_g_set_error(context, error, G_MARKUP_ERROR,
|
||||||
G_MARKUP_ERROR_MISSING_ATTRIBUTE,
|
G_MARKUP_ERROR_MISSING_ATTRIBUTE,
|
||||||
"Missing attribute: mnc");
|
"Missing attribute: mnc");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,9 +252,9 @@ static void apn_handler(GMarkupParseContext *context, struct gsm_data *gsm,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (apn == NULL) {
|
if (apn == NULL) {
|
||||||
g_set_error(error, G_MARKUP_ERROR,
|
mbpi_g_set_error(context, error, G_MARKUP_ERROR,
|
||||||
G_MARKUP_ERROR_MISSING_ATTRIBUTE,
|
G_MARKUP_ERROR_MISSING_ATTRIBUTE,
|
||||||
"APN attribute missing");
|
"APN attribute missing");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,8 +281,8 @@ static void gsm_start(GMarkupParseContext *context, const gchar *element_name,
|
||||||
if (gsm->match_found == TRUE)
|
if (gsm->match_found == TRUE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
network_id_handler(userdata, attribute_names, attribute_values,
|
network_id_handler(context, userdata, attribute_names,
|
||||||
error);
|
attribute_values, error);
|
||||||
} else if (g_str_equal(element_name, "apn"))
|
} else if (g_str_equal(element_name, "apn"))
|
||||||
apn_handler(context, userdata, attribute_names,
|
apn_handler(context, userdata, attribute_names,
|
||||||
attribute_values, error);
|
attribute_values, error);
|
||||||
|
@ -293,9 +312,9 @@ static void gsm_end(GMarkupParseContext *context, const gchar *element_name,
|
||||||
if (pd->type != apn->type)
|
if (pd->type != apn->type)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
g_set_error(error, mbpi_error_quark(),
|
mbpi_g_set_error(context, error, mbpi_error_quark(),
|
||||||
MBPI_ERROR_DUPLICATE,
|
MBPI_ERROR_DUPLICATE,
|
||||||
"Duplicate context detected");
|
"Duplicate context detected");
|
||||||
|
|
||||||
mbpi_provision_data_free(apn);
|
mbpi_provision_data_free(apn);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue