From 62ba3b30d2cd337ab3f453849605d8efd79f2cc9 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Wed, 9 Dec 2009 12:50:52 -0600 Subject: [PATCH] Use at_util_parse_reg in netreg driver --- drivers/atmodem/network-registration.c | 57 +++----------------------- 1 file changed, 6 insertions(+), 51 deletions(-) diff --git a/drivers/atmodem/network-registration.c b/drivers/atmodem/network-registration.c index 038bda29..d7950d75 100644 --- a/drivers/atmodem/network-registration.c +++ b/drivers/atmodem/network-registration.c @@ -66,11 +66,8 @@ static void extract_mcc_mnc(const char *str, char *mcc, char *mnc) static void at_creg_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct cb_data *cbd = user_data; - GAtResultIter iter; ofono_netreg_status_cb_t cb = cbd->cb; - int status; - const char *str; - int lac = -1, ci = -1, tech = -1; + int status, lac, ci, tech; struct ofono_error error; dump_response("at_creg_cb", ok, result); @@ -81,33 +78,12 @@ static void at_creg_cb(gboolean ok, GAtResult *result, gpointer user_data) return; } - g_at_result_iter_init(&iter, result); - - if (!g_at_result_iter_next(&iter, "+CREG:")) { + if (at_util_parse_reg(result, "+CREG:", NULL, &status, + &lac, &ci, &tech) == FALSE) { CALLBACK_WITH_FAILURE(cb, -1, -1, -1, -1, cbd->data); return; } - /* Skip the unsolicited result code */ - g_at_result_iter_skip_next(&iter); - - g_at_result_iter_next_number(&iter, &status); - - if (g_at_result_iter_next_string(&iter, &str) == TRUE) - lac = strtol(str, NULL, 16); - else - goto out; - - if (g_at_result_iter_next_string(&iter, &str) == TRUE) - ci = strtol(str, NULL, 16); - else - goto out; - - g_at_result_iter_next_number(&iter, &tech); - -out: - ofono_debug("creg_cb: %d, %d, %d, %d", status, lac, ci, tech); - cb(&error, status, lac, ci, tech, cbd->data); } @@ -649,35 +625,14 @@ error: static void creg_notify(GAtResult *result, gpointer user_data) { struct ofono_netreg *netreg = user_data; - GAtResultIter iter; - int status; - int lac = -1, ci = -1, tech = -1; - const char *str; + int status, lac, ci, tech; dump_response("creg_notify", TRUE, result); - g_at_result_iter_init(&iter, result); - - if (!g_at_result_iter_next(&iter, "+CREG:")) + if (at_util_parse_reg_unsolicited(result, "+CREG:", &status, + &lac, &ci, &tech) == FALSE) return; - g_at_result_iter_next_number(&iter, &status); - - if (g_at_result_iter_next_string(&iter, &str) == TRUE) - lac = strtol(str, NULL, 16); - else - goto out; - - if (g_at_result_iter_next_string(&iter, &str) == TRUE) - ci = strtol(str, NULL, 16); - else - goto out; - - g_at_result_iter_next_number(&iter, &tech); - -out: - ofono_debug("creg_notify: %d, %d, %d, %d", status, lac, ci, tech); - ofono_netreg_status_notify(netreg, status, lac, ci, tech); }