Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp835552ybx; Fri, 1 Nov 2019 12:01:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQ8Ir/1uDFNudX4CTD80RaCN10MD4KtwmczzUPSmt/trdhI1Fv0NnPb20Job7++WUEuWjy X-Received: by 2002:a17:906:79c9:: with SMTP id m9mr11044738ejo.297.1572634872805; Fri, 01 Nov 2019 12:01:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572634872; cv=none; d=google.com; s=arc-20160816; b=vLpLfQCpSmzYKA+3RURpTR6f1LJbJeQ8ApZejd6GjYJexvpJWgC+WhxY4klNT5K8oB lLCihIDvUADrQCjrOAVt2erHuoG/2eIxyRZqUPnWpbiezOYogoEK8ki4SHzyeiHMNKbN 3TPgS4j0+1B9IYn6Vc6ftgCzl4g8cGOiiJ3CySZrTxiPYmH9+qrI0J6IeBjpBYCqILBn FRB7r+7MU8/weolE6gA2pBb8T2ZZNPVORsTBIFKuOtzMykrsdpJX1iLiXe6lVE18Hfs4 IIQpsMmGy2cvyAbOzjoV2DAYsrYbyjueQsp4eTIQOXU3bQWhdI7OiD8B7yqbcAGv/JnN p04A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=C6gqLv31TMAvmpzqJkN4Y0UmPqhuduOE568AKf9acdU=; b=h/MshHoG5MhybdX16Q48PfAbvmNadONLhNGTWQJis1m6t8D3mEJE65gyISDlds4aMs zPccoDhbq5EOom2HzldSJT1YRuPQOkYvZWxA2cr3EISphCMxlaphhPNbCx4XKuBfY/iA NP3vtqdNYkz/rEGvp6j09gaqrG0CURI/KRWyCT7m7HxyF6gG+lI75kUcRHuWr75y3H+E VFjgi8nYhOcfKf0xSqwZjk3GsYVO4uNA5SobdpE8bHWdzAM8RgB5RqSefnAR8+vXJHOj DZe0kjMzyIclS3wDPAdRRcYV5q4VvIabLGd3uDDHdlqb7/Y1waYt61OfYPygC1D3oZE4 vvbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b15si6600211ejd.66.2019.11.01.12.00.47; Fri, 01 Nov 2019 12:01:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727325AbfKAS5c (ORCPT + 99 others); Fri, 1 Nov 2019 14:57:32 -0400 Received: from mga05.intel.com ([192.55.52.43]:29978 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727372AbfKAS5c (ORCPT ); Fri, 1 Nov 2019 14:57:32 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Nov 2019 11:57:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,256,1569308400"; d="scan'208";a="211833706" Received: from ingas-nuc1.sea.intel.com ([10.255.230.110]) by fmsmga001.fm.intel.com with ESMTP; 01 Nov 2019 11:57:31 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ 01/10 v2] tools/mesh: Remove extra dependencies from agent.c Date: Fri, 1 Nov 2019 11:57:20 -0700 Message-Id: <20191101185729.31661-2-inga.stotland@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191101185729.31661-1-inga.stotland@intel.com> References: <20191101185729.31661-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This removes dependency on glib and mesh/util.c. Also, fixes few style glitches. --- tools/mesh/agent.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/tools/mesh/agent.c b/tools/mesh/agent.c index 08e498541..0ec76f3b7 100644 --- a/tools/mesh/agent.c +++ b/tools/mesh/agent.c @@ -30,12 +30,9 @@ #include #include -#include - #include #include "src/shared/shell.h" -#include "tools/mesh/util.h" #include "tools/mesh/agent.h" struct input_request { @@ -63,6 +60,22 @@ static void reset_input_request(void) pending_request.user_data = NULL; } +static bool str2hex(const char *str, uint16_t in_len, uint8_t *out, + uint16_t out_len) +{ + uint16_t i; + + if (in_len < out_len * 2) + return false; + + for (i = 0; i < out_len; i++) { + if (sscanf(&str[i * 2], "%02hhx", &out[i]) != 1) + return false; + } + + return true; +} + static void response_hexadecimal(const char *input, void *user_data) { uint8_t buf[MAX_HEXADECIMAL_OOB_LEN]; @@ -111,8 +124,8 @@ static bool request_hexadecimal(uint16_t len) return false; bt_shell_printf("Request hexadecimal key (hex %d octets)\n", len); - bt_shell_prompt_input("mesh", "Enter key (hex number):", response_hexadecimal, - NULL); + bt_shell_prompt_input("mesh", "Enter key (hex number):", + response_hexadecimal, NULL); return true; } @@ -130,7 +143,8 @@ static uint32_t power_ten(uint8_t power) static bool request_decimal(uint16_t len) { bt_shell_printf("Request decimal key (0 - %d)\n", power_ten(len) - 1); - bt_shell_prompt_input("mesh", "Enter Numeric key:", response_decimal, NULL); + bt_shell_prompt_input("mesh-agent", "Enter Numeric key:", + response_decimal, NULL); return true; } @@ -141,8 +155,8 @@ static bool request_ascii(uint16_t len) return false; bt_shell_printf("Request ASCII key (max characters %d)\n", len); - bt_shell_prompt_input("mesh", "Enter key (ascii string):", response_ascii, - NULL); + bt_shell_prompt_input("mesh", "Enter key (ascii string):", + response_ascii, NULL); return true; } @@ -153,7 +167,7 @@ bool agent_input_request(oob_type_t type, uint16_t max_len, agent_input_cb cb, bool result; if (pending_request.type != NONE) - return FALSE; + return false; switch (type) { case HEXADECIMAL: -- 2.21.0