From patchwork Mon Nov 22 21:45:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 582 Return-Path: Received: from fmmailgate01.web.de (fmmailgate01.web.de [217.72.192.221]) by open-mesh.org (Postfix) with ESMTP id 5888E154568 for ; Mon, 22 Nov 2010 22:46:46 +0100 (CET) Received: from smtp05.web.de ( [172.20.4.166]) by fmmailgate01.web.de (Postfix) with ESMTP id 6C8FC17B96BB6; Mon, 22 Nov 2010 22:45:59 +0100 (CET) Received: from [46.126.246.98] (helo=localhost) by smtp05.web.de with asmtp (TLSv1:AES128-SHA:128) (WEB.DE 4.110 #24) id 1PKeD1-0004gB-00; Mon, 22 Nov 2010 22:45:59 +0100 From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: b.a.t.m.a.n@lists.open-mesh.org Date: Mon, 22 Nov 2010 22:45:54 +0100 Message-Id: <1290462354-17246-2-git-send-email-linus.luessing@ascom.ch> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1290462354-17246-1-git-send-email-linus.luessing@ascom.ch> References: <1290462354-17246-1-git-send-email-linus.luessing@ascom.ch> MIME-Version: 1.0 Sender: linus.luessing@web.de X-Sender: linus.luessing@web.de X-Provags-ID: V01U2FsdGVkX18kS3q5xnOljHz6rP1Nxd7PYnAYhG6AEcdOSqz+ UF/p3J2ULJ5qUJOiFreW3S7I4GhsjvbNqXlN0kMoOFsohlJBBv n3WWJmAEDniVa1MvMlBA== Cc: =?UTF-8?q?Linus=20L=C3=BCssing?= Subject: [B.A.T.M.A.N.] [PATCH 2/2] batctl: Fix (skipped) substitutions of mac addresses X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Nov 2010 21:46:46 -0000 This patch fixes two parts: For one thing "batctl l" won't remove commas anymore if it cannot find the mac address in the bat-hosts file. For another, it now allows the correct substitution of mac addresses which have the suffix ')'. Signed-off-by: Linus Lüssing --- functions.c | 24 ++++++++++++++++-------- 1 files changed, 16 insertions(+), 8 deletions(-) diff --git a/functions.c b/functions.c index ce046ba..52cfe4b 100644 --- a/functions.c +++ b/functions.c @@ -177,9 +177,17 @@ read: *space_ptr = '\0'; extra_char = '\0'; - if ((strlen(buff_ptr) == ETH_STR_LEN + 1) && (buff_ptr[ETH_STR_LEN] == ',')) { - extra_char = ','; - buff_ptr[ETH_STR_LEN] = '\0'; + if (strlen(buff_ptr) == ETH_STR_LEN + 1) { + extra_char = buff_ptr[ETH_STR_LEN]; + switch (extra_char) { + case ',': + case ')': + buff_ptr[ETH_STR_LEN] = '\0'; + break; + default: + extra_char = '\0'; + break; + } } if (strlen(buff_ptr) != ETH_STR_LEN) @@ -201,16 +209,16 @@ read: /* keep table format */ printf("%17s", bat_host->name); - if (extra_char != '\0') - printf("%c", extra_char); - - printf(" "); goto written; print_plain_buff: - printf("%s ", buff_ptr); + printf("%s", buff_ptr); written: + if (extra_char != '\0') + printf("%c", extra_char); + + printf(" "); buff_ptr = space_ptr + 1; }