Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1700406rwb; Thu, 15 Dec 2022 13:16:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf7buuouNSia1N5gbvGhr9nKLreyV+k7MCFN76AbZxwkkOfR/+hjI5KAPGCVUsnRupScJlAF X-Received: by 2002:a17:903:2641:b0:189:7f28:43a7 with SMTP id je1-20020a170903264100b001897f2843a7mr29011600plb.29.1671138997266; Thu, 15 Dec 2022 13:16:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671138997; cv=none; d=google.com; s=arc-20160816; b=Kz3d9+fY31QFJS+bS08RWDA4UnP6Lc5HMoypMbjqIl0NZ43sPW0MrrS9yV4iYT0jlj PF0pvMHon6dJYOVLRlmZ5JnxJoHyN2CEYpeCNbQCuz02WHEuzo98PLTHnjZsHOJQof4/ 9kZBX6OoCSUe65U1J+Y4xUeCf+b2xIcOArwZuVM80M3C3kaeeUklZRnA3wK+GZoSZujR XbLw44QjxnLZsSePBNvDGUQq4XLnbXTyNWc2Uh/m320wY0lsE3ozrD/qI0iFT5IjEgFZ joyKAnA8PfGnOjb4dacQld+RGcbf9poB5vwlzbv0K4QdhYKBLcgcVl3ztHcbc6ig56vk rQZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=dk4rLbDdNGWPnvC7kri4rqAgpOPPYTq/B4Hcvj14rhk=; b=PTsezX8dfR4YID8RbSbc7BT8kdUHL90o5akz6XDtLgK9AWECT74reuCjkoM9kWDvS3 CI+uHjxH1K5epr8fBADajUlb9bdMgq0Ajzlw4f9NQqzSGQjCA8df2nIwHh+37KjCMSdO icABSDmEFma7HhWdFURF5+hNSucM6IzXoKNK+pU6Wfa+EBIGmZCrMvbnd4XQcqTMwnx6 GRUWa+gp3JZx3bFtLzTLU5XqCXWiEKHfb/gjZAPMMLwrcmjYoXGHQtLQBlv5iMJuQrvp pQRraMJIbgZ+YXzKZq+W8cTT9rxu4aByE7u7DAgbgBZoR/guomUMbyKIOGfdrrCYICNf OTEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UrVuo5UB; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x62-20020a636341000000b00480a937f897si494302pgb.650.2022.12.15.13.16.19; Thu, 15 Dec 2022 13:16:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UrVuo5UB; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229661AbiLOVK4 (ORCPT + 99 others); Thu, 15 Dec 2022 16:10:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229809AbiLOVKn (ORCPT ); Thu, 15 Dec 2022 16:10:43 -0500 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C21C410B6 for ; Thu, 15 Dec 2022 13:10:41 -0800 (PST) Received: by mail-pf1-x435.google.com with SMTP id 21so460717pfw.4 for ; Thu, 15 Dec 2022 13:10:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=dk4rLbDdNGWPnvC7kri4rqAgpOPPYTq/B4Hcvj14rhk=; b=UrVuo5UBwk3FFGlu8ZD0pBTckYfmCdK3nKDJ2XNw9Iwwry5gbzLcBzPZjXml0bbu6H lLoI39fbyLmh1owGVHUcUgDDrJ0luEO+75IAZudUUPb0Uo/gz8gYljs9gf8GN3oXod5R 8by8zBkmg8QQ4G0RHluW2kQUo/DfdokIiMW6g+LNorpromJd2SasRDDWgEhRWIacPK9y 2t4JNlAw/cl/qgYDeH25+csGv64OKB/Bb30FCXOkmQcCCSbcxCByjWlsyd37qo93dTVM ayn/49lvai7oUbiyFFBbLyP0j47K32A/+wdDN4Xp0xWptKJcu4408biKgoCEedMT0N/D gsGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dk4rLbDdNGWPnvC7kri4rqAgpOPPYTq/B4Hcvj14rhk=; b=kjGwCtzmsAdoPiM9KDkRLjpzWxaWMWp8vh/xVkZOxeYYosX3ItX51fm7Pxp5Un3Yh8 OfimmkkBSfRsR/22hmQky6mUSa2N76SEXvsmAkPpo/1IGRXu9AKVV+TH8otzLQlVIGal qdG6sDVgQMlClK65vpe+prITQ/tgUcBdidu3xaLNTXTsQYCMWqc83qHy7GW6gAs/xpUD Slrs4ye+CMEUMQssMP+S8UoswVqlbsm43lZcwvt3GDHuq2rICeN/Yr5AZnBIp5RBh+g1 YSXoVsgTywpank+/mZH3MWl1GNp/eDszXVwCuZohqP2xpzq6ZspGQz1EURjcFBSIq9sP Uvfg== X-Gm-Message-State: ANoB5plfdMrRp8+uR4xY5v+6sLloSqNYqsJmnUGryTvOU9gSoPADz4V6 ua3cx9FCQgcfNbJ0sbku5blVVM1GaCjOwFOa X-Received: by 2002:a05:6a00:1696:b0:566:94d0:8c96 with SMTP id k22-20020a056a00169600b0056694d08c96mr38971495pfc.26.1671138640775; Thu, 15 Dec 2022 13:10:40 -0800 (PST) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id c20-20020aa79534000000b005779110635asm54908pfp.51.2022.12.15.13.10.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 13:10:40 -0800 (PST) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v2 2/5] shared/shell: Add bt_shell_echo Date: Thu, 15 Dec 2022 13:10:34 -0800 Message-Id: <20221215211037.2686489-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221215211037.2686489-1-luiz.dentz@gmail.com> References: <20221215211037.2686489-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds bt_shell_echo which can be used to print messages on the echo area. --- src/shared/shell.c | 20 ++++++++++++++++++++ src/shared/shell.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/src/shared/shell.c b/src/shared/shell.c index 0639c786d983..3c0e61dbc414 100644 --- a/src/shared/shell.c +++ b/src/shared/shell.c @@ -576,6 +576,26 @@ void bt_shell_printf(const char *fmt, ...) } } +void bt_shell_echo(const char *fmt, ...) +{ + va_list args; + char *str; + int err; + + va_start(args, fmt); + err = vasprintf(&str, fmt, args); + if (!err) + err = asprintf(&str, COLOR_HIGHLIGHT "%s#" COLOR_OFF, str); + va_end(args); + + if (err) + return; + + rl_save_prompt(); + bt_shell_set_prompt(str); + rl_restore_prompt(); +} + static void print_string(const char *str, void *user_data) { bt_shell_printf("%s\n", str); diff --git a/src/shared/shell.h b/src/shared/shell.h index 8baa2854a250..87fb5c415f20 100644 --- a/src/shared/shell.h +++ b/src/shared/shell.h @@ -70,6 +70,8 @@ void bt_shell_set_prompt(const char *string); void bt_shell_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); +void bt_shell_echo(const char *fmt, + ...) __attribute__((format(printf, 1, 2))); void bt_shell_hexdump(const unsigned char *buf, size_t len); void bt_shell_usage(void); -- 2.37.3