From patchwork Tue Feb 13 15:35:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13555258 Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E7665FF18 for ; Tue, 13 Feb 2024 15:36:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707838574; cv=none; b=l7X1f1jCg7V/6Lt8o/GqFnbqRdbBF/lFwRgFmOFBQxqkz1XxqjsEjMWAdXzlzOgZ7e5gjHarYkVckf88Ehd50HWhOVn+RjZWLyvP/yLHwSZi36NUqTgvEA1aQhyPsIOpzn7V/Lz5zOk397j6BS+p/X769mz3Q2YsnIQz+Al4vq0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707838574; c=relaxed/simple; bh=+EVAxLMO+PfbilI2o6Yzx5GIE07Z0j+hnPEKifAYhqs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=CKwsHEvKTJ+ptJ0dZpUsxk5YkTD+W/Otd2u8GjiV8GiY2yulX8U8swOQttv9TXbNPYb+jPIqc8d0kjb5teefpM8y6cNfBbJ4bMq4aebhQp/p0OaZdW6VtZSbOjNwr6qJ4gpy4Dwff5fDfkRUALniQiaFK/G0hFp2v4eufiF7++E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=h19Q7Egk; arc=none smtp.client-ip=209.85.167.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="h19Q7Egk" Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-3c0449eaadaso778468b6e.1 for ; Tue, 13 Feb 2024 07:36:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707838572; x=1708443372; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=KdFTkdy8sVoQJ1BpsIrIdTM3Q0WaZNcs+I2zHkvL5zo=; b=h19Q7EgkieOzgKjwRzq8sDIFt2Xt4R7tl6/d/vEiYFZ5cuTtpHVHD36IQV3yUbB2IA Zafz+TU3Rktqnj7g2jGrIOIoPR1EkLq02HtLKaRssjPO7Oh0TdPlkuZrfgByS36rhG2k L0jE+zK0FpxA8GmBzHryHc7uWpkKlqkilZwSMhuyE69ay7taA97PuXDPo5WisztiLy3w +aGzeTs8fFjAmOdDnHhIUkN2YDUPfv7dYUWoYd4CZn+zEvZEHcogB05YIJIs7PiPk6K3 xUarduSSv6p9AQ+YEnBL3bG1LauGf1jsffjF+YMoaM3tVryCYshhSAhBFqat/4Wzjijo pY1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707838572; x=1708443372; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KdFTkdy8sVoQJ1BpsIrIdTM3Q0WaZNcs+I2zHkvL5zo=; b=S3wS8Mo+X4YH5sYwapj4H127G3vO1EXhPNFCdxKdBygtZqWuYn3byQiby+DxrJDON8 qAkRYM6Mhqp61pdGP9ALbnck6t2QFLTTiIeXEzte9NJQzPzh8O8UhN16dgMhNJ64Ap0l tfVOnyXDXB0qcpSRqLWnvkeWJJh9xudtHH6G0fvptTxRvQeYJos8Uk0xWWWNMuQ4WSc/ F3FT2mFfsaVxl9m6bhNkGncJUYidoCpIZSNGaivCNGPQI4XVjrECzbDa1yJJVnDqoftl 8zYo/lFxlrHECRsZBP62q2lAddZDF1tZE3X6XRMlA+ZI1lAfBXaLi+XY6UPETaaVUZLj X0sw== X-Gm-Message-State: AOJu0YyjKIoDkoBNEZUwTt9FLGGKUGvVjO0J2HuICc/0OQt2C8mmt8An n/e7N80EkzCyTeNJgOqjmsx+baOKvEW6Qc+AIFH9IGytGGEaqFIjdAyEtcvg X-Google-Smtp-Source: AGHT+IGpT10BabIgawb6UMinGqFUkjx1zk9pS/R4LdGGzxlxqT4HAZybkNAWj0pUPDw6TMqu2IsY0g== X-Received: by 2002:a05:6870:b09:b0:219:7535:8d50 with SMTP id lh9-20020a0568700b0900b0021975358d50mr10714845oab.23.1707838571878; Tue, 13 Feb 2024 07:36:11 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id dx19-20020a056870769300b0021a0f032341sm1861999oab.22.2024.02.13.07.36.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 07:36:11 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 1/6] sim: Drop glib use from sim_efli_format Date: Tue, 13 Feb 2024 09:35:05 -0600 Message-ID: <20240213153524.1085649-1-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Change the return signature to use bool instead of gboolean. Also, change g_ascii_isalpha use to l_ascii_isalpha. While here, also update array subscripts to follow the coding style, item M3 --- src/sim.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/sim.c b/src/sim.c index 33d00ac9a615..55ff5f448647 100644 --- a/src/sim.c +++ b/src/sim.c @@ -2155,15 +2155,15 @@ static void sim_efli_read_cb(int ok, int length, int record, } /* Detect whether the file is in EFli format, as opposed to 51.011 EFlp */ -static gboolean sim_efli_format(const unsigned char *ef, int length) +static bool sim_efli_format(const unsigned char *ef, int length) { int i; if (length & 1) - return FALSE; + return false; for (i = 0; i < length; i += 2) { - if (ef[i] == 0xff && ef[i+1] == 0xff) + if (ef[i] == 0xff && ef[i + 1] == 0xff) continue; /* @@ -2171,14 +2171,14 @@ static gboolean sim_efli_format(const unsigned char *ef, int length) * characters while CB DCS language codes are in ranges * (0 - 15) or (32 - 47), so the ranges don't overlap */ - if (g_ascii_isalpha(ef[i]) == 0) - return FALSE; + if (l_ascii_isalpha(ef[i]) == 0) + return false; - if (g_ascii_isalpha(ef[i+1]) == 0) - return FALSE; + if (l_ascii_isalpha(ef[i + 1]) == 0) + return false; } - return TRUE; + return true; } static GSList *parse_language_list(const unsigned char *ef, int length) @@ -2261,7 +2261,7 @@ static void sim_efpl_read_cb(int ok, int length, int record, struct ofono_sim *sim = userdata; const char *path = __ofono_atom_get_path(sim->atom); DBusConnection *conn = ofono_dbus_get_connection(); - gboolean efli_format = TRUE; + bool efli_format = true; GSList *efli = NULL; GSList *efpl = NULL; From patchwork Tue Feb 13 15:35:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13555259 Received: from mail-oa1-f41.google.com (mail-oa1-f41.google.com [209.85.160.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A83875FF19 for ; Tue, 13 Feb 2024 15:36:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707838575; cv=none; b=F4qOCDoMrJ+iRqREcwBVI+/OECrsYhDZZ7ux9qq3OBZAUJbrwxEhlp7tRxBtSIExWJ3svcXykqJWrsEnaA9wZ2frzjeNYoqgIOVMyeEAmNfjI9ifrF97TLxAi0825UfTGiU+I+qms8IstEjLClUaODsORYS723dsDZIYz3NIovc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707838575; c=relaxed/simple; bh=51KlFVjVQQBgV3dUwrvr6pRVrkInm1p0OJThcE4BxXg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qgxz/djGlHojR5BMgeGGFfoXCJiPnYuCo0CiwKPS7PuOgNAntIIMBOyTTL6hR022XDT03o86AXjbM2c5u55aqz/9o7pqCWI6VkriEc8IAJcg5fZf5Rj/rzWpHjJygqoZRZilR12mkBAF0OZNyYHzru2NwgnwTlrX5IZWaosYx6g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NijWO2kM; arc=none smtp.client-ip=209.85.160.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NijWO2kM" Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-21922481a2fso3205298fac.0 for ; Tue, 13 Feb 2024 07:36:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707838572; x=1708443372; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+KU8714d1Ytb8k6N+teFTUslr4KoUAjWHuKOPRIzJEs=; b=NijWO2kMKUZmcyR9UT5kiPa6ouuvsipFU+LlDAx2tqpvTLUjS3fQRChTvb51Yk4DEL B0lJRGyFjFNVNtV5Y+7S7nZ3MYHf/kmPzm/jo/X6qhJdVGOy4O7hstdrrix74B04awth z7+oxwG9dPvECNALf4OaWYvgzr6nhzoOBrJ49sTBfzRG8xRLZ5cNnEujEvBacAA36TCX ce40EPQmty/L5WkDdPP64Q1qJj4t14eHgyMp6fAEl4a0LHG5tKQQmAEst69cxwBSwG0H W5EkJWXAdzpg0hJK+nqaOLmVpyrgpPasc6faWLyCHSXUaRxTBWffs5XYTadShIVSIxNR Nzog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707838572; x=1708443372; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+KU8714d1Ytb8k6N+teFTUslr4KoUAjWHuKOPRIzJEs=; b=j4tk9huzTn1MtRRVSDSaPH4CuEz/QTDSBP8bjxRCbisfKYCb37JS5tlFoHvgUGR7OE oRoR5T8b6TvVjgJFOUeRrBvGSyQ9ivmuWt+BPHQUpgiS5sXY/lJgnKICOzsq628TIno2 WI5tydk07EfafQGBC5Qr6XQ3r/4Cu+2ELmh3txKXXPNKiVF9HizWTzFT5DF0MfNMKiuQ YUObuHj+4i9OwHrBU/3ouZrzoY3wrCRLuBOsUUhRiOU9mixKHQPNp6x/8d9G6/396BF1 kKJTlZdgPL5El1IsaWPq/gpkbpat65LIwo4BP8X0/N3BMMjX3kOefgh03lFagmm+dcdG UMxg== X-Gm-Message-State: AOJu0Yyw61ZcTOfj2enWjS/melJFBH8C3oDx4JwMdFrC1QUAyGMG5M12 xpWnfSvwjxsHry2SJ0bpsBFbD6muxKSuN3fr3Cgvpzzz4eQgzluW8pKpYZlK X-Google-Smtp-Source: AGHT+IFZ7dqSrvmnjUZ17l4pGTW8vnXpPU8OUMRsDfvJOzdtBv1JzKOKIDAtTPhabLNYl4NucYMaEQ== X-Received: by 2002:a05:6870:4723:b0:219:3054:3ea5 with SMTP id b35-20020a056870472300b0021930543ea5mr10147385oaq.45.1707838572595; Tue, 13 Feb 2024 07:36:12 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id dx19-20020a056870769300b0021a0f032341sm1861999oab.22.2024.02.13.07.36.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 07:36:12 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 2/6] smsutil: Move iso639_2_from_language to util Date: Tue, 13 Feb 2024 09:35:06 -0600 Message-ID: <20240213153524.1085649-2-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213153524.1085649-1-denkenz@gmail.com> References: <20240213153524.1085649-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Also while here, convert to using stdbool instead of gboolean --- src/sim.c | 2 +- src/smsutil.c | 111 -------------------------------------------------- src/smsutil.h | 27 +----------- src/util.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/util.h | 26 ++++++++++++ 5 files changed, 140 insertions(+), 137 deletions(-) diff --git a/src/sim.c b/src/sim.c index 55ff5f448647..fedd000923b9 100644 --- a/src/sim.c +++ b/src/sim.c @@ -2211,7 +2211,7 @@ static GSList *parse_eflp(const unsigned char *eflp, int length) GSList *ret = NULL; for (i = 0; i < length; i++) { - if (iso639_2_from_language(eflp[i], code) == FALSE) + if (!iso639_2_from_language(eflp[i], code)) continue; ret = g_slist_prepend(ret, g_strdup(code)); diff --git a/src/smsutil.c b/src/smsutil.c index f46507f00e1c..d4f28c01bd79 100644 --- a/src/smsutil.c +++ b/src/smsutil.c @@ -3937,117 +3937,6 @@ gboolean cbs_extract_app_port(const struct cbs *cbs, int *dst, int *src, return extract_app_port_common(&iter, dst, src, is_8bit); } -gboolean iso639_2_from_language(enum cbs_language lang, char *iso639) -{ - switch (lang) { - case CBS_LANGUAGE_GERMAN: - iso639[0] = 'd'; - iso639[1] = 'e'; - iso639[2] = '\0'; - return TRUE; - case CBS_LANGUAGE_ENGLISH: - iso639[0] = 'e'; - iso639[1] = 'n'; - iso639[2] = '\0'; - return TRUE; - case CBS_LANGUAGE_ITALIAN: - iso639[0] = 'i'; - iso639[1] = 't'; - iso639[2] = '\0'; - return TRUE; - case CBS_LANGUAGE_FRENCH: - iso639[0] = 'f'; - iso639[1] = 'r'; - iso639[2] = '\0'; - return TRUE; - case CBS_LANGUAGE_SPANISH: - iso639[0] = 'e'; - iso639[1] = 's'; - iso639[2] = '\0'; - return TRUE; - case CBS_LANGUAGE_DUTCH: - iso639[0] = 'n'; - iso639[1] = 'l'; - iso639[2] = '\0'; - return TRUE; - case CBS_LANGUAGE_SWEDISH: - iso639[0] = 's'; - iso639[1] = 'v'; - iso639[2] = '\0'; - return TRUE; - case CBS_LANGUAGE_DANISH: - iso639[0] = 'd'; - iso639[1] = 'a'; - iso639[2] = '\0'; - return TRUE; - case CBS_LANGUAGE_PORTUGESE: - iso639[0] = 'p'; - iso639[1] = 't'; - iso639[2] = '\0'; - return TRUE; - case CBS_LANGUAGE_FINNISH: - iso639[0] = 'f'; - iso639[1] = 'i'; - iso639[2] = '\0'; - return TRUE; - case CBS_LANGUAGE_NORWEGIAN: - iso639[0] = 'n'; - iso639[1] = 'o'; - iso639[2] = '\0'; - return TRUE; - case CBS_LANGUAGE_GREEK: - iso639[0] = 'e'; - iso639[1] = 'l'; - iso639[2] = '\0'; - return TRUE; - case CBS_LANGUAGE_TURKISH: - iso639[0] = 't'; - iso639[1] = 'r'; - iso639[2] = '\0'; - return TRUE; - case CBS_LANGUAGE_HUNGARIAN: - iso639[0] = 'h'; - iso639[1] = 'u'; - iso639[2] = '\0'; - return TRUE; - case CBS_LANGUAGE_POLISH: - iso639[0] = 'p'; - iso639[1] = 'l'; - iso639[2] = '\0'; - return TRUE; - case CBS_LANGUAGE_CZECH: - iso639[0] = 'c'; - iso639[1] = 's'; - iso639[2] = '\0'; - return TRUE; - case CBS_LANGUAGE_HEBREW: - iso639[0] = 'h'; - iso639[1] = 'e'; - iso639[2] = '\0'; - return TRUE; - case CBS_LANGUAGE_ARABIC: - iso639[0] = 'a'; - iso639[1] = 'r'; - iso639[2] = '\0'; - return TRUE; - case CBS_LANGUAGE_RUSSIAN: - iso639[0] = 'r'; - iso639[1] = 'u'; - iso639[2] = '\0'; - return TRUE; - case CBS_LANGUAGE_ICELANDIC: - iso639[0] = 'i'; - iso639[1] = 's'; - iso639[2] = '\0'; - return TRUE; - default: - iso639[0] = '\0'; - break; - } - - return FALSE; -} - char *cbs_decode_text(GSList *cbs_list, char *iso639_lang) { GSList *l; diff --git a/src/smsutil.h b/src/smsutil.h index 01487de4b67c..5389757c309c 100644 --- a/src/smsutil.h +++ b/src/smsutil.h @@ -19,6 +19,8 @@ * */ +enum cbs_language; + #define CBS_MAX_GSM_CHARS 93 #define SMS_MSGID_LEN 20 @@ -196,30 +198,6 @@ enum sms_pid_type { SMS_PID_TYPE_USIM_DOWNLOAD = 0x7f, }; -enum cbs_language { - CBS_LANGUAGE_GERMAN = 0x0, - CBS_LANGUAGE_ENGLISH = 0x1, - CBS_LANGUAGE_ITALIAN = 0x2, - CBS_LANGUAGE_FRENCH = 0x3, - CBS_LANGUAGE_SPANISH = 0x4, - CBS_LANGUAGE_DUTCH = 0x5, - CBS_LANGUAGE_SWEDISH = 0x6, - CBS_LANGUAGE_DANISH = 0x7, - CBS_LANGUAGE_PORTUGESE = 0x8, - CBS_LANGUAGE_FINNISH = 0x9, - CBS_LANGUAGE_NORWEGIAN = 0xA, - CBS_LANGUAGE_GREEK = 0xB, - CBS_LANGUAGE_TURKISH = 0xC, - CBS_LANGUAGE_HUNGARIAN = 0xD, - CBS_LANGUAGE_POLISH = 0xE, - CBS_LANGUAGE_UNSPECIFIED = 0xF, - CBS_LANGUAGE_CZECH = 0x20, - CBS_LANGUAGE_HEBREW = 0x21, - CBS_LANGUAGE_ARABIC = 0x22, - CBS_LANGUAGE_RUSSIAN = 0x23, - CBS_LANGUAGE_ICELANDIC = 0x24 -}; - enum cbs_geo_scope { CBS_GEO_SCOPE_CELL_IMMEDIATE, CBS_GEO_SCOPE_PLMN, @@ -576,7 +554,6 @@ gboolean cbs_dcs_decode(guint8 dcs, gboolean *udhi, enum sms_class *cls, enum sms_charset *charset, gboolean *compressed, enum cbs_language *language, gboolean *iso639); -gboolean iso639_2_from_language(enum cbs_language lang, char *iso639); gboolean cbs_decode(const unsigned char *pdu, int len, struct cbs *out); gboolean cbs_encode(const struct cbs *cbs, int *len, unsigned char *pdu); gboolean cbs_extract_app_port(const struct cbs *cbs, int *dst, int *src, diff --git a/src/util.c b/src/util.c index 627be7eec097..0a5212a2bca4 100644 --- a/src/util.c +++ b/src/util.c @@ -3753,3 +3753,114 @@ unsigned char *convert_ucs2_to_gsm(const unsigned char *text, long len, GSM_DIALECT_DEFAULT, GSM_DIALECT_DEFAULT); } + +bool iso639_2_from_language(enum cbs_language lang, char *iso639) +{ + switch (lang) { + case CBS_LANGUAGE_GERMAN: + iso639[0] = 'd'; + iso639[1] = 'e'; + iso639[2] = '\0'; + return true; + case CBS_LANGUAGE_ENGLISH: + iso639[0] = 'e'; + iso639[1] = 'n'; + iso639[2] = '\0'; + return true; + case CBS_LANGUAGE_ITALIAN: + iso639[0] = 'i'; + iso639[1] = 't'; + iso639[2] = '\0'; + return true; + case CBS_LANGUAGE_FRENCH: + iso639[0] = 'f'; + iso639[1] = 'r'; + iso639[2] = '\0'; + return true; + case CBS_LANGUAGE_SPANISH: + iso639[0] = 'e'; + iso639[1] = 's'; + iso639[2] = '\0'; + return true; + case CBS_LANGUAGE_DUTCH: + iso639[0] = 'n'; + iso639[1] = 'l'; + iso639[2] = '\0'; + return true; + case CBS_LANGUAGE_SWEDISH: + iso639[0] = 's'; + iso639[1] = 'v'; + iso639[2] = '\0'; + return true; + case CBS_LANGUAGE_DANISH: + iso639[0] = 'd'; + iso639[1] = 'a'; + iso639[2] = '\0'; + return true; + case CBS_LANGUAGE_PORTUGESE: + iso639[0] = 'p'; + iso639[1] = 't'; + iso639[2] = '\0'; + return true; + case CBS_LANGUAGE_FINNISH: + iso639[0] = 'f'; + iso639[1] = 'i'; + iso639[2] = '\0'; + return true; + case CBS_LANGUAGE_NORWEGIAN: + iso639[0] = 'n'; + iso639[1] = 'o'; + iso639[2] = '\0'; + return true; + case CBS_LANGUAGE_GREEK: + iso639[0] = 'e'; + iso639[1] = 'l'; + iso639[2] = '\0'; + return true; + case CBS_LANGUAGE_TURKISH: + iso639[0] = 't'; + iso639[1] = 'r'; + iso639[2] = '\0'; + return true; + case CBS_LANGUAGE_HUNGARIAN: + iso639[0] = 'h'; + iso639[1] = 'u'; + iso639[2] = '\0'; + return true; + case CBS_LANGUAGE_POLISH: + iso639[0] = 'p'; + iso639[1] = 'l'; + iso639[2] = '\0'; + return true; + case CBS_LANGUAGE_CZECH: + iso639[0] = 'c'; + iso639[1] = 's'; + iso639[2] = '\0'; + return true; + case CBS_LANGUAGE_HEBREW: + iso639[0] = 'h'; + iso639[1] = 'e'; + iso639[2] = '\0'; + return true; + case CBS_LANGUAGE_ARABIC: + iso639[0] = 'a'; + iso639[1] = 'r'; + iso639[2] = '\0'; + return true; + case CBS_LANGUAGE_RUSSIAN: + iso639[0] = 'r'; + iso639[1] = 'u'; + iso639[2] = '\0'; + return true; + case CBS_LANGUAGE_ICELANDIC: + iso639[0] = 'i'; + iso639[1] = 's'; + iso639[2] = '\0'; + return true; + default: + iso639[0] = '\0'; + break; + } + + return false; +} diff --git a/src/util.h b/src/util.h index 3e7dfea3e8bc..a70fb49f7ae5 100644 --- a/src/util.h +++ b/src/util.h @@ -38,6 +38,30 @@ enum gsm_dialect { GSM_DIALECT_URDU, }; +enum cbs_language { + CBS_LANGUAGE_GERMAN = 0x0, + CBS_LANGUAGE_ENGLISH = 0x1, + CBS_LANGUAGE_ITALIAN = 0x2, + CBS_LANGUAGE_FRENCH = 0x3, + CBS_LANGUAGE_SPANISH = 0x4, + CBS_LANGUAGE_DUTCH = 0x5, + CBS_LANGUAGE_SWEDISH = 0x6, + CBS_LANGUAGE_DANISH = 0x7, + CBS_LANGUAGE_PORTUGESE = 0x8, + CBS_LANGUAGE_FINNISH = 0x9, + CBS_LANGUAGE_NORWEGIAN = 0xA, + CBS_LANGUAGE_GREEK = 0xB, + CBS_LANGUAGE_TURKISH = 0xC, + CBS_LANGUAGE_HUNGARIAN = 0xD, + CBS_LANGUAGE_POLISH = 0xE, + CBS_LANGUAGE_UNSPECIFIED = 0xF, + CBS_LANGUAGE_CZECH = 0x20, + CBS_LANGUAGE_HEBREW = 0x21, + CBS_LANGUAGE_ARABIC = 0x22, + CBS_LANGUAGE_RUSSIAN = 0x23, + CBS_LANGUAGE_ICELANDIC = 0x24 +}; + char *convert_gsm_to_utf8(const unsigned char *text, long len, long *items_read, long *items_written, unsigned char terminator); @@ -105,3 +129,5 @@ unsigned char *convert_ucs2_to_gsm_with_lang(const unsigned char *text, unsigned char *convert_ucs2_to_gsm(const unsigned char *text, long len, long *items_read, long *items_written, unsigned char terminator); + +bool iso639_2_from_language(enum cbs_language lang, char *iso639); From patchwork Tue Feb 13 15:35:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13555263 Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC71F5FF1B for ; Tue, 13 Feb 2024 15:36:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707838578; cv=none; b=QAf2GqKJuqmmKFwgS1CN7HPqYrdNFMANSgOZ9d0kLH6oO+o4Rkm+mRuSN2qYI6Ml+vOLel7lG9jl1VlxGMXBJj86nquYuNT2Gexf0xDdwcNr5BP91LWJqlr4LNedyHnjpupjGna5OPtnetBXdezDq0VZx0x7j/6p8v/8x0DoDuQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707838578; c=relaxed/simple; bh=h2hJ4Ktyc2i/lCDojdXVgQqe5ggpbiZv9if2lBthzHA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AvcPSVxPkAmsh+VvP+wppJ6LSVuflPlWZI7aOvEyDnHmKVfNLIcWi6FdIRjD1jjJJpcqVTdTDV1gQAUMsW8ttlxdj6x5v4EBocll+ZVJ81xqC6ylZINhKI+Db+DsWZuBMgXDE9n72abHb5RyQ7ZrLWtNDWvu2PRICY2KTL5EBFs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WEq3Sdkj; arc=none smtp.client-ip=209.85.160.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WEq3Sdkj" Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-2143a96d185so1749427fac.3 for ; Tue, 13 Feb 2024 07:36:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707838573; x=1708443373; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UcAQYr+tce1lCp4HP52ymPttjWw9ZOyZfu3oIqmrmOU=; b=WEq3SdkjeQBp0mL34dkc3f06YI/eUKkLFqyMPZjfW/w8gSs+hvQq8K/sBZL9avOQ8t NXN2XehMh9SNZO1SSCZBQbF1tSf/+vqopZQrvUlEp35ue/2eQPRjY3WT0CgEe0ADn3dx U1GfmBgF6/nw+VkNwq1QCF9hA/xz3+CDfPQdujcw+i1H3M0R6XPkhmC6ycLGETHbGZM7 klASW/EQuTR4Nzs8hznQHk7jAw1llYDCCFDzdhw5eFddhKaRkqtkTzk05hyqUl8fO+pY rjIVHrOyxRwQihKfcwt4OB4Ahm7zliE4eUwOG1gfVbyf3t161W4CWyXbtr2ZJKrr0liy SRGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707838573; x=1708443373; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UcAQYr+tce1lCp4HP52ymPttjWw9ZOyZfu3oIqmrmOU=; b=RfaPDMEDgWVWtiT+4T5eRXhVdGu5E8uxeSz7RWxVNuUrM5WLGofai+LzNZVZaIxU+X 9ODFZPlvltg2f0IT1ImPtMucjFTSZKGMHrtj5xCCEIQdu79+e5AoejC4FNkxPI1uzD+i TRRLNtpGg4J3+7IFIvDmnz/wX+UKmjQYiuks0ero7PlOBJGD2zoF5ueCzfx+5MSY17dH 1ZH7MeIuUe/VfQefnQFGHcycN5T2Honv/0huxwfF/Ja8Lwdn74zf6cY/7nA9QmxZes0W f9njMOjLhl8Qc/LpJ85PGSEACKyYy4WqhwBLZP/y5XUbkkQbLl00QNfFs0X8qh1dV4SU RhUQ== X-Gm-Message-State: AOJu0YxGIZMmRcrGT24IoKaTeFocVLmwnL2y3V56aoAW7Baf3T7oPJmX BuTWD/mKxXLjAmpyluJ6F3Yg03ipyLt6QwdWoxGKfdLy1Vm4Et13DxWfKHsA X-Google-Smtp-Source: AGHT+IE94GLheiLE3FzQD8Ej1CMEpuSITSz5QyEaSJpH7feT3Ksx06F1mwBzKsXLGFNkUYGr6QB7gQ== X-Received: by 2002:a05:6870:b6a6:b0:214:2e69:c04a with SMTP id cy38-20020a056870b6a600b002142e69c04amr8884027oab.22.1707838573251; Tue, 13 Feb 2024 07:36:13 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id dx19-20020a056870769300b0021a0f032341sm1861999oab.22.2024.02.13.07.36.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 07:36:13 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 3/6] sim: Move EFli and EFlp parsers to simutil Date: Tue, 13 Feb 2024 09:35:07 -0600 Message-ID: <20240213153524.1085649-3-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213153524.1085649-1-denkenz@gmail.com> References: <20240213153524.1085649-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 While here, convert from using g_slist to l_strv utilities and remove other GLib usage. --- src/sim.c | 105 ++++++++++++++------------------------------------ src/simutil.c | 62 +++++++++++++++++++++++++++++ src/simutil.h | 3 ++ 3 files changed, 93 insertions(+), 77 deletions(-) diff --git a/src/sim.c b/src/sim.c index fedd000923b9..1873eccccf2e 100644 --- a/src/sim.c +++ b/src/sim.c @@ -2181,76 +2181,33 @@ static bool sim_efli_format(const unsigned char *ef, int length) return true; } -static GSList *parse_language_list(const unsigned char *ef, int length) +static char **concat_lang_prefs(char **a, char **b) { - int i; - GSList *ret = NULL; - - for (i = 0; i < length; i += 2) { - if (ef[i] > 0x7f || ef[i+1] > 0x7f) - continue; - - /* - * ISO 639 codes contain only characters that are coded - * identically in SMS 7 bit charset, ASCII or UTF8 so - * no conversion. - */ - ret = g_slist_prepend(ret, g_ascii_strdown((char *)ef + i, 2)); - } - - if (ret) - ret = g_slist_reverse(ret); - - return ret; -} - -static GSList *parse_eflp(const unsigned char *eflp, int length) -{ - int i; - char code[3]; - GSList *ret = NULL; - - for (i = 0; i < length; i++) { - if (!iso639_2_from_language(eflp[i], code)) - continue; - - ret = g_slist_prepend(ret, g_strdup(code)); - } - - if (ret) - ret = g_slist_reverse(ret); - - return ret; -} - -static char **concat_lang_prefs(GSList *a, GSList *b) -{ - GSList *l, *k; char **ret; - int i = 0; - int total = g_slist_length(a) + g_slist_length(b); + int i; + int j; + int total = l_strv_length(a) + l_strv_length(b); if (total == 0) return NULL; - ret = g_new0(char *, total + 1); - - for (l = a; l; l = l->next) - ret[i++] = g_strdup(l->data); - - for (l = b; l; l = l->next) { - gboolean duplicate = FALSE; + ret = l_new(char *, total + 1); - for (k = a; k; k = k->next) - if (!strcmp(k->data, l->data)) - duplicate = TRUE; + for (i = 0; a && a[i]; i++) + ret[i] = a[i]; - if (duplicate) + for (j = 0; b && b[j]; j++) { + if (l_strv_contains(a, b[j])) { + l_free(b[j]); continue; + } - ret[i++] = g_strdup(l->data); + ret[i++] = b[j]; } + l_free(a); + l_free(b); + return ret; } @@ -2262,22 +2219,23 @@ static void sim_efpl_read_cb(int ok, int length, int record, const char *path = __ofono_atom_get_path(sim->atom); DBusConnection *conn = ofono_dbus_get_connection(); bool efli_format = true; - GSList *efli = NULL; - GSList *efpl = NULL; + char **efli = NULL; + char **efpl = NULL; if (!ok || length < 2) goto skip_efpl; - efpl = parse_language_list(data, length); + efpl = sim_parse_language_list(data, length); skip_efpl: if (sim->efli && sim->efli_length > 0) { efli_format = sim_efli_format(sim->efli, sim->efli_length); if (efli_format) - efli = parse_language_list(sim->efli, sim->efli_length); + efli = sim_parse_language_list(sim->efli, + sim->efli_length); else - efli = parse_eflp(sim->efli, sim->efli_length); + efli = sim_parse_eflp(sim->efli, sim->efli_length); } /* @@ -2293,13 +2251,14 @@ skip_efpl: */ if (efli_format) { if (sim->efli_length >= 2 && sim->efli[0] == 0xff && - sim->efli[1] == 0xff) - sim->language_prefs = concat_lang_prefs(NULL, efpl); - else - sim->language_prefs = concat_lang_prefs(efli, efpl); - } else { + sim->efli[1] == 0xff) { + l_strfreev(efli); + efli = NULL; + } + + sim->language_prefs = concat_lang_prefs(efli, efpl); + } else sim->language_prefs = concat_lang_prefs(efpl, efli); - } if (sim->efli) { g_free(sim->efli); @@ -2307,14 +2266,6 @@ skip_efpl: sim->efli_length = 0; } - if (efli) { - g_slist_free_full(efli, g_free); - } - - if (efpl) { - g_slist_free_full(efpl, g_free); - } - if (sim->language_prefs != NULL) ofono_dbus_signal_array_property_changed(conn, path, OFONO_SIM_MANAGER_INTERFACE, diff --git a/src/simutil.c b/src/simutil.c index 0354cafd087f..7345f38db571 100644 --- a/src/simutil.c +++ b/src/simutil.c @@ -1827,3 +1827,65 @@ gboolean sim_parse_gsm_authenticate(const unsigned char *buffer, int len, gsm_end: return FALSE; } + +char **sim_parse_language_list(const unsigned char *ef, int length) +{ + int i; + size_t n_languages = 0; + char **ret; + + for (i = 0; i + 1 < length; i += 2) { + if (ef[i] > 0x7f || ef[i + 1] > 0x7f) + continue; + + n_languages += 1; + } + + if (!n_languages) + return NULL; + + ret = l_new(char *, n_languages + 1); + + for (i = 0, n_languages = 0; i + 1 < length; i += 2) { + if (ef[i] > 0x7f || ef[i + 1] > 0x7f) + continue; + + /* + * ISO 639 codes contain only characters that are coded + * identically in SMS 7 bit charset, ASCII or UTF8 so + * no conversion. + */ + ret[n_languages++] = l_ascii_strdown((const char *)ef + i, 2); + } + + return ret; +} + +char **sim_parse_eflp(const unsigned char *eflp, int length) +{ + int i; + char code[3]; + char **ret; + size_t n_languages = 0; + + for (i = 0; i < length; i++) { + if (!iso639_2_from_language(eflp[i], code)) + continue; + + n_languages += 1; + } + + if (!n_languages) + return NULL; + + ret = l_new(char *, n_languages + 1); + + for (i = 0, n_languages = 0; i < length; i++) { + if (!iso639_2_from_language(eflp[i], code)) + continue; + + ret[n_languages++] = l_strdup(code); + } + + return ret; +} diff --git a/src/simutil.h b/src/simutil.h index fd3967ffd336..9584d4d9cd62 100644 --- a/src/simutil.h +++ b/src/simutil.h @@ -541,3 +541,6 @@ gboolean sim_parse_umts_authenticate(const unsigned char *buffer, int len, gboolean sim_parse_gsm_authenticate(const unsigned char *buffer, int len, const unsigned char **sres, const unsigned char **kc); + +char **sim_parse_language_list(const unsigned char *ef, int length); +char **sim_parse_eflp(const unsigned char *eflp, int length); From patchwork Tue Feb 13 15:35:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13555260 Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BF935EE98 for ; Tue, 13 Feb 2024 15:36:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707838576; cv=none; b=PuFz1aCj44hSed+EDUijaBtWbooNAb5vy3Oy1lUtaj5ipwUBkgqg7JuvAa/PTpEkrm7Yca8/6cGRPzrLnZjC6xOxc0tobzwKa2L0QCOT8ryTPEG42LAFLPowKbr2KHYbeAun0nXd6dyzAigIffrLQZLV0FNEHlrKj7E6NKBCkkg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707838576; c=relaxed/simple; bh=uYF2A5QkuGe5qWaVBjlbOZP+SXkn8oGryV/1TStSD+c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cMnMen7USq59R+vBXUwYK1vCVTyPRpFU+wXvA9r145fzgjdMZ9Gpn68yFWgH+HNygiAofqMjzpSvS6iulgdEbZB+/tXP5zLlEPBjJEsMhs66ErW2c5ClcsqYawwX9pekOYlov2hVnZx46JGAJaQCNveIZYVoJL51BJX9EakVPdY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cFH4SRja; arc=none smtp.client-ip=209.85.160.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cFH4SRja" Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-218e3197784so2740520fac.0 for ; Tue, 13 Feb 2024 07:36:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707838574; x=1708443374; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=USCgKvrth+Jll5yk+iyO/1iEpkZViw7E+RT05XL2yCA=; b=cFH4SRjai/fik5Qso8gFRC4WYHcAdYnUOISAdZ+KwRa9pdsTmxTqwT5wVJ/qEELL/Q O1Age6me4hVw72hXnMkr4pWEVKBqAGFU9nwVGCYun2QtscWN5+cN8Ph6zNFrDOqhgJB4 7WLhyBJc+RJ5qzTPA3rYGoCfiSF6ikpEvkKEO6xg1kkaH/zO34m/nPnveeJZlo+SrzIV E87tUdvuY/Lw1Ltq33oZ3fmPU2PSg+p8ExWOBsNVWIZ6/QyXEGCvdpGrukYc/WKTYGi1 WF5OJYGjs12fB/GX3INpvnD01TAxJN1kjQqsrHs7srwmAy2LYbYBfs8dKuDENBm6pjCL duxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707838574; x=1708443374; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=USCgKvrth+Jll5yk+iyO/1iEpkZViw7E+RT05XL2yCA=; b=l8xVyW7ELKp8bUmr4A2om9nD+8D8brps3r4/KkpDMEtCi3SMtzQeJAN8OuVF6tKXI2 56gJtzPlrkiKP4tgXbpoV9syLG/J7SEEfEeFuVBkd0CXyVsfeymv61mQwB/wE60c6Nlo zBcig8tLwJM7h/karNRcM7mHMftR4qlev5AScCA+3rZK1XPIP5XtHmFNvhcWJN0tHzYJ 0AzmefC/v0SfcY1GU7I/N9m4GrhzOHydMmEYLeyUhtC03SqXTLBmLCyciHQYruz92J95 TZZ5KLfcXOq+IsgjODl53r2GyoswARG5fz9RTj/fX+aKejyUnWDkFvaQnVfvcHaj52r/ SF8A== X-Gm-Message-State: AOJu0YzxP7O58/VoI4u3PqiHhFG2Yaznoz1NVzQle18JwlRjimbjkI28 /VzAIHd0az2po3cLFXCzzsDvpnztmOoxKXAooIknXmBRKUXzBqM8yGHH5BVZ X-Google-Smtp-Source: AGHT+IGNzxsjIYjBIC37FvsfmxnXPvbme98gYD26sLYZldCw9Z7FJenybQaB4gbuxHbXu+0/eZ06AQ== X-Received: by 2002:a05:6871:5316:b0:219:a838:df with SMTP id hx22-20020a056871531600b00219a83800dfmr12943426oac.49.1707838573998; Tue, 13 Feb 2024 07:36:13 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id dx19-20020a056870769300b0021a0f032341sm1861999oab.22.2024.02.13.07.36.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 07:36:13 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 4/6] unit: Add unit tests for language list parsers Date: Tue, 13 Feb 2024 09:35:08 -0600 Message-ID: <20240213153524.1085649-4-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213153524.1085649-1-denkenz@gmail.com> References: <20240213153524.1085649-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add unit tests for the newly moved sim_parse_language_list and sim_parse_eflp functions. --- unit/test-simutil.c | 57 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/unit/test-simutil.c b/unit/test-simutil.c index 8364f200c665..4199991a4d2a 100644 --- a/unit/test-simutil.c +++ b/unit/test-simutil.c @@ -695,6 +695,59 @@ static void test_auth_build_parse(void) g_assert(!memcmp(kc_b.data, kc, sizeof(kc))); } +static void test_parse_language_list(void) +{ + static const unsigned char empty[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff + }; + static const unsigned char efpl[] = { + 'e', 'n', 0xff, 0xff, 'd', 'e', 'f', 'r', 0xff, 0xff, 'n', 'l' + }; + + char **parsed; + char *joined; + + parsed = sim_parse_language_list(empty, sizeof(empty)); + assert(!parsed); + + parsed = sim_parse_language_list(efpl, sizeof(efpl)); + assert(parsed); + joined = l_strjoinv(parsed, ':'); + assert(!strcmp(joined, "en:de:fr:nl")); + l_strfreev(parsed); + l_free(joined); + + parsed = sim_parse_language_list(efpl, sizeof(efpl) - 1); + assert(parsed); + joined = l_strjoinv(parsed, ':'); + assert(!strcmp(joined, "en:de:fr")); + l_strfreev(parsed); + l_free(joined); +} + +static void test_parse_eflp(void) +{ + static const unsigned char empty[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff + }; + static const unsigned char eflp[] = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 + }; + + char **parsed; + char *joined; + + parsed = sim_parse_eflp(empty, sizeof(empty)); + assert(!parsed); + + parsed = sim_parse_eflp(eflp, sizeof(eflp)); + assert(parsed); + joined = l_strjoinv(parsed, ':'); + assert(!strcmp(joined, "de:en:it:fr:es:nl")); + l_strfreev(parsed); + l_free(joined); +} + int main(int argc, char **argv) { g_test_init(&argc, &argv, NULL); @@ -716,5 +769,9 @@ int main(int argc, char **argv) g_test_add_func("/testsimutil/2G path", test_get_2g_path); g_test_add_func("/testsimutil/auth build parse", test_auth_build_parse); + g_test_add_func("/testsimutil/parse_language_list", + test_parse_language_list); + g_test_add_func("/testsimutil/parse_efpl", test_parse_eflp); + return g_test_run(); } From patchwork Tue Feb 13 15:35:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13555261 Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4CF06024C for ; Tue, 13 Feb 2024 15:36:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707838577; cv=none; b=BxggVkWk2VIFPpsaBWAYLM0zTZ+h6cmQiYrpCjt52AFYCSFWjZOKBt3z+22yCk5Rh6GhWKUEKjpSBuC8j1jaxyLA1NFnNt0qXcShdcAWJ53ZX4u2YV6/6QBm9qpfnymoN7H//ZxlxvSTKxL5H3jodZsCLDw+fOOc43FIkKDlkEc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707838577; c=relaxed/simple; bh=KoFSdFBDVpGkZnow4+flSvzZ2Y55ie+K6Lw2RlH2zuE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ICu0/jU2qxJT+jerSD6c7n3k4ifZQATLx532L+RdCMYOi24h59JTkAG+r6Va+wCXUkTDplz+9HGRlO4jqqsxbQh3KHtmWEFqst4wQTMRcwYCA1jrMUXjc/zcuqP/UFzRx+IacgVnzBYgRr7xIXdhONZCEpB1cqil2jf66ARNLPg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dDWfMWgh; arc=none smtp.client-ip=209.85.210.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dDWfMWgh" Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-6e2e096e2ccso1197159a34.2 for ; Tue, 13 Feb 2024 07:36:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707838574; x=1708443374; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5MDt7A1RKLfY2mHyxrWs3iK4/BNy7KuvqoNiIF0syrM=; b=dDWfMWghiiIByGPW+H/ROoqa3a86M//2X+cs/5Xiu5vJPuuwLemxN+epWbljW+OHfr Pr5fXblVt+9T5b6cItJiMh+wrwh1mrWKnJNO8xbUCKi4WMszpjQcS6UGXbajpvos1Ww9 pTXw/LHYUPvqogeZaqXyZrgMAjheB1GcOF9u44k6YVCsaEc7Fsbb1HkbBR0j3pCQNrxP Jm+7R5x/P7PWFtpJ4jlYdjpb7KfCHl294gX0yiDHc+IHEUY0XrsIkLGRBEKvFPI8RiW0 S+oAWbdzV624WbTrwqI1wfYb0WrkB1zXnWzcxAjSnPA6yeNuALfkDt1d3A7O2eR0ksGR OgrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707838574; x=1708443374; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5MDt7A1RKLfY2mHyxrWs3iK4/BNy7KuvqoNiIF0syrM=; b=bSP/mWJAbZWs+UNepjBsueNTxUMkMliG8sECWcVsej2GU25OoDGYBp5+ZjBJPYPupn Pe4jscQS8MzfSHHjsqEBdNGw1r2ckwfTii/BoQOXn6xmXh3cou8kAbnsgZaKThVb4qdi xl2r5m93Co1DcSXhheQa/sP5fLETS2sJj6I4nI2ui/ukj9ZMsxKOMZJz94+6ir2zNn8P bLlA4g36tEGh7pLXxOuQZ09jnc2mg2q+jzw2r76zeBthVUfudzG7kst9Pvvdhv1fD8bq Ie2QYoszS+I+LWeO73QOgmtFg4ExoXVjDrozK3RwNfozvWkHQZklGFbbggtNJN+eyCU6 8MOQ== X-Gm-Message-State: AOJu0YyB2MTVaxuyNa+LFPYmo+9aruze6IqJ7BXy6kWzORzjuhb38A59 em7pbuVIZcRrayUfytcYjCwuYtANYWlkcBSk7BSDuP9/uZyW6h+EccWA6EEq X-Google-Smtp-Source: AGHT+IF9gPqsRHe8EJuJCFEqr1aQGJKY48R9OWedtc/9nIDwdK8PHGyawsgNXNxms6hi4tyWscJNdA== X-Received: by 2002:a05:6871:293:b0:21a:4820:7ed8 with SMTP id i19-20020a056871029300b0021a48207ed8mr7428474oae.8.1707838574591; Tue, 13 Feb 2024 07:36:14 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id dx19-20020a056870769300b0021a0f032341sm1861999oab.22.2024.02.13.07.36.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 07:36:14 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 5/6] common: Convert use of g_ascii* to ell Date: Tue, 13 Feb 2024 09:35:09 -0600 Message-ID: <20240213153524.1085649-5-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213153524.1085649-1-denkenz@gmail.com> References: <20240213153524.1085649-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Also remove the glib header include since no other GLib use remains. --- src/common.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/common.c b/src/common.c index 859f146702ec..aff356da3330 100644 --- a/src/common.c +++ b/src/common.c @@ -27,7 +27,6 @@ #include #include -#include #include #include @@ -561,7 +560,7 @@ gboolean parse_ss_control_string(char *str, int *ss_type, goto out; for (i = 0; i < strlen(*sc); i++) - if (!g_ascii_isdigit((*sc)[i])) + if (!l_ascii_isdigit((*sc)[i])) goto out; NEXT_FIELD(c, *sia); @@ -681,7 +680,7 @@ gboolean is_valid_apn(const char *apn) return FALSE; for (i = 0; apn[i] != '\0'; i++) { - if (g_ascii_isalnum(apn[i])) + if (l_ascii_isalnum(apn[i])) continue; if (apn[i] == '-') From patchwork Tue Feb 13 15:35:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13555262 Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 672A15EE9A for ; Tue, 13 Feb 2024 15:36:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707838577; cv=none; b=scUKiBb026EumNwfjiwSBVqUmkS+trLINKVnmVy2xW57GSl2NeWDaFavyq3+zNnTBoOh+REzgvPX1kiXixK41/ntYbQxWDq0B5VguFp+pFlg3xv9u/uDb1bZVSZgXtyzVe8NmwIMH1EWOvE+KkiOTCXtj+qnTGPiSyBDwY3z+Cg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707838577; c=relaxed/simple; bh=eJ6nrOIwhi1CPG+9SRHOFoXsGzzUSb0vwkuCql1nRvo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fxxCV/2p+EsBnJTx4GaxRe/NtkSZn4xb7U21KAktuE9ZYRd97focXcetqD0WhU0nJynOePnc4ujd4+8IcA964c0yPYWAUbwdp8Y3ulHtCSkElidpcvN/shYX+zbYROHIP91pf7LdOJm/RFrTpmIrjIlLivYcmQlvuKuDWf4b/ZA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MSLzRjxA; arc=none smtp.client-ip=209.85.160.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MSLzRjxA" Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-21922481a2fso3205326fac.0 for ; Tue, 13 Feb 2024 07:36:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707838575; x=1708443375; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FTxsjo8hIK25nH0xgPFBXvm3G6xa0W1atRTbQwHO/fo=; b=MSLzRjxA5WxcL+xzejbhkSkm4ICE7Q+9R0z1TABRLqB49z3lZVjWN1BSCOvd2nQwco C075ookR+xO+8nVnGynvJX8gCRKNZKf8MVJAun4zOO72HcduHfeulC8VqwUy2a14x4Ou qhKPo/LKwY+o4LlDj5Dy76j68DBdZ+MTdk3FiFuNW+hVJ5bFWnTBCRhDFpvUVKQB2ci2 7I0pYbBma8cm/5QyhQQ3Kq5LX5CZIunTesmBgh/YfS+Yavw/K0IoKAIvh+cr9cjffaIu KUXRhM0zHUy2B39Syf2NiagkWFpOmMEBh6c3GCp5CEIk1qv174W9KBdXQ41Izh17NK1Y 7lrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707838575; x=1708443375; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FTxsjo8hIK25nH0xgPFBXvm3G6xa0W1atRTbQwHO/fo=; b=NtyAb8Qa1ccFngc7P/KHdQjTOr3BijQxl8E4Z3FXdyCJ7WWrtxCYtIfN1oC/0PvjKo TzfVYJCTb5gZtPz9ycsLz2UxK7z3x/1SNhDPRfoVtwVP72kkAEk8SMjVfGd5/m+BWYzs N7bT+civ7do6pS/O1V60cV/id8AElo6mZe3EA8FoP+wNZPwSJNXiGNZ+OSVSJKCbFbFs 0Ddwglj9zlMO6ckQDEcbF4tC8ZgBwlr5MQ3ZSIRY8e6IhOC5BoxfXSddJZRZcYEvddTS Nhy74WlsZPSyBzfv0TSykG1ZHEPnzr/sD2rkZ2K97pCkYbx/NqX3O0BsyPsGryJuRnxy 6F6w== X-Gm-Message-State: AOJu0YxH6NPfM4IhMpLzPC8pjDHtywpxRt5izNvf3L3seVsbdILBjX6G Z6gxU854Eiin1Dwh1qkGa5zr9cc1qjgFaw7lRHt3DfsmXQUpHlw0Ny7oNtBy X-Google-Smtp-Source: AGHT+IF7LnCf+FiuUfoyfPlvr6Z6aB+WzkgPQcaBpPvhV8SOCQImviWdYbPeKDhXikJCwYUZAmg/mw== X-Received: by 2002:a05:6870:d88d:b0:21a:fb2:9e1b with SMTP id oe13-20020a056870d88d00b0021a0fb29e1bmr9822585oac.16.1707838575330; Tue, 13 Feb 2024 07:36:15 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id dx19-20020a056870769300b0021a0f032341sm1861999oab.22.2024.02.13.07.36.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 07:36:15 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 6/6] voicecall: Convert use of g_ascii* to ell Date: Tue, 13 Feb 2024 09:35:10 -0600 Message-ID: <20240213153524.1085649-6-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213153524.1085649-1-denkenz@gmail.com> References: <20240213153524.1085649-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/voicecall.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/voicecall.c b/src/voicecall.c index fcfbfcb24513..6d677a9a7487 100644 --- a/src/voicecall.c +++ b/src/voicecall.c @@ -340,7 +340,7 @@ static int tone_queue(struct ofono_voicecall *vc, const char *tone_str, * and p for Pause. */ for (i = 0; tone_str[i]; i++) - if (!g_ascii_isdigit(tone_str[i]) && tone_str[i] != 'p' && + if (!l_ascii_isdigit(tone_str[i]) && tone_str[i] != 'p' && tone_str[i] != 'P' && tone_str[i] != '*' && tone_str[i] != '#' && (tone_str[i] < 'A' || tone_str[i] > 'D')) @@ -2196,11 +2196,9 @@ static DBusMessage *manager_tone(DBusConnection *conn, if (len == 0) return __ofono_error_invalid_format(msg); - tones = g_ascii_strup(in_tones, len); - + tones = l_ascii_strup(in_tones, len); err = tone_queue(vc, tones, tone_callback, vc, NULL); - - g_free(tones); + l_free(tones); if (err < 0) return __ofono_error_invalid_format(msg); @@ -3440,7 +3438,7 @@ static void emulator_vts_cb(struct ofono_emulator *em, if (str == NULL) break; - if (!g_ascii_isdigit(str[0]) && str[0] != '*' && + if (!l_ascii_isdigit(str[0]) && str[0] != '*' && str[0] != '#' && (str[0] < 'A' || str[0] > 'D')) break;