From patchwork Fri Aug 16 21:05:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 19254 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gh0-f197.google.com (mail-gh0-f197.google.com [209.85.160.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 42B50248E6 for ; Fri, 16 Aug 2013 21:06:17 +0000 (UTC) Received: by mail-gh0-f197.google.com with SMTP id r20sf2626467ghr.4 for ; Fri, 16 Aug 2013 14:06:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=fugXa82WsLN1X0lvrvvgajPeC3dTa4yP2DJ6JESo1M0=; b=O4Yc4enbpleMJdRmA96v4mL1LNAYqne5hhKb/GqFMUiBZrRzFKRAYQcEZwnMBVicV9 /3ulPtVtiNz4kGBCW+9/tCYvkCeWpm0u8rT5SmJ0+2F3vhS8wYuaySQWP0CvCVHMPxJz YmC5q5k9vJ8i0bNOAd3wShvECUkvRINNki+VdXdsq4nwuJOo46axNKlpNVYA8MUFEBD0 aM2zuN8E4HRIebWSLzB0kUcYyevSaUR2Sm8WVBK8Fg+R2iERRHbCg72lIu0noM7KQQUv pjzQ76iiGVKA2IY5agk4iipQYr1NuIWnM6yAbUj9cwBQL9C+JqdlHjpf8pj/Re5gUmH+ BRpQ== X-Received: by 10.236.176.134 with SMTP id b6mr1245398yhm.46.1376687176973; Fri, 16 Aug 2013 14:06:16 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.101.44 with SMTP id fd12ls890730qeb.98.gmail; Fri, 16 Aug 2013 14:06:16 -0700 (PDT) X-Received: by 10.52.103.35 with SMTP id ft3mr2479020vdb.5.1376687176846; Fri, 16 Aug 2013 14:06:16 -0700 (PDT) Received: from mail-vb0-f49.google.com (mail-vb0-f49.google.com [209.85.212.49]) by mx.google.com with ESMTPS id fb4si777162veb.88.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 Aug 2013 14:06:16 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.49 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.49; Received: by mail-vb0-f49.google.com with SMTP id w16so1928776vbb.22 for ; Fri, 16 Aug 2013 14:06:16 -0700 (PDT) X-Gm-Message-State: ALoCoQkXYg/EDF/t+YVgpbza5wzGSWp8n6S7eEgsGCQxpw3ERGfh1wHq6tP9zq/TZHgqaJPwg3xd X-Received: by 10.220.249.67 with SMTP id mj3mr2901058vcb.23.1376687176764; Fri, 16 Aug 2013 14:06:16 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp89442vcz; Fri, 16 Aug 2013 14:06:16 -0700 (PDT) X-Received: by 10.194.123.199 with SMTP id mc7mr2524378wjb.43.1376687175781; Fri, 16 Aug 2013 14:06:15 -0700 (PDT) Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by mx.google.com with ESMTPS id y7si239005wij.39.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 Aug 2013 14:06:15 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.180 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=209.85.212.180; Received: by mail-wi0-f180.google.com with SMTP id f14so1238890wiw.1 for ; Fri, 16 Aug 2013 14:06:15 -0700 (PDT) X-Received: by 10.180.24.234 with SMTP id x10mr549831wif.47.1376687175217; Fri, 16 Aug 2013 14:06:15 -0700 (PDT) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id b13sm797327wic.9.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 Aug 2013 14:06:14 -0700 (PDT) From: Julien Grall To: stefano.stabellini@eu.citrix.com, ian.campbell@citrix.com Cc: patches@linaro.org, andre.przywara@linaro.org, xen-devel@lists.xen.org, Julien Grall Subject: [RFC 06/24] xen: Add new string functions Date: Fri, 16 Aug 2013 22:05:38 +0100 Message-Id: <1376687156-6737-7-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1376687156-6737-1-git-send-email-julien.grall@linaro.org> References: <1376687156-6737-1-git-send-email-julien.grall@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.49 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add kbasename and strcasecmp. The code is copied from Linux. Signed-off-by: Julien Grall --- xen/common/string.c | 15 +++++++++++++++ xen/include/xen/string.h | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/xen/common/string.c b/xen/common/string.c index db9d9d5..9a5a4ba 100644 --- a/xen/common/string.c +++ b/xen/common/string.c @@ -41,6 +41,21 @@ int strnicmp(const char *s1, const char *s2, size_t len) } #endif +#ifndef __HAVE_ARCH_STRCASECMP +int strcasecmp(const char *s1, const char *s2) +{ + int c1, c2; + + do + { + c1 = tolower(*s1++); + c2 = tolower(*s2++); + } while ( c1 == c2 && c1 != 0 ); + + return c1 - c2; +} +#endif + #ifndef __HAVE_ARCH_STRLCPY /** * strlcpy - Copy a %NUL terminated string into a sized buffer diff --git a/xen/include/xen/string.h b/xen/include/xen/string.h index f26b994..9b7511e 100644 --- a/xen/include/xen/string.h +++ b/xen/include/xen/string.h @@ -43,6 +43,9 @@ extern int strncmp(const char *,const char *,__kernel_size_t); #ifndef __HAVE_ARCH_STRNICMP extern int strnicmp(const char *, const char *, __kernel_size_t); #endif +#ifndef __HAVE_ARCH_STRCASECMP +extern int strcasecmp(const char *, const char *); +#endif #ifndef __HAVE_ARCH_STRCHR extern char * strchr(const char *,int); #endif @@ -94,4 +97,15 @@ extern void * memchr(const void *,int,__kernel_size_t); (strlcat(d, s, sizeof(d)) >= sizeof(d)); \ }) +/** + * kbasename - return the last part of a pathname. + * + * @path: path to extract the filename from. + */ +static inline const char *kbasename(const char *path) +{ + const char *tail = strrchr(path, '/'); + return tail ? tail + 1 : path; +} + #endif /* _LINUX_STRING_H_ */