master
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.se/docs/copyright.html.
13 *
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24#include "curl_setup.h"
26#include "strcase.h"
28/*
29 * curl_strequal() is for doing "raw" case insensitive strings. This is meant
30 * to be locale independent and only compare strings we know are safe for
31 * this. See https://daniel.haxx.se/blog/2008/10/15/strcasecmp-in-turkish/ for
32 * further explanations as to why this function is necessary.
33 */
35static int casecompare(const char *first, const char *second)
36{
37 while(*first) {
38 if(Curl_raw_toupper(*first) != Curl_raw_toupper(*second))
39 /* get out of the loop as soon as they do not match */
40 return 0;
41 first++;
42 second++;
43 }
44 /* If we are here either the strings are the same or the length is different.
45 We can test if the "current" character is non-zero for one and zero
46 for the other. Note that the characters may not be exactly the same even
47 if they match, we only want to compare zero-ness. */
48 return !*first == !*second;
49}
51static int ncasecompare(const char *first, const char *second, size_t max)
52{
53 while(*first && max) {
54 if(Curl_raw_toupper(*first) != Curl_raw_toupper(*second))
55 return 0;
56 max--;
57 first++;
58 second++;
59 }
60 if(max == 0)
61 return 1; /* they are equal this far */
63 return Curl_raw_toupper(*first) == Curl_raw_toupper(*second);
64}
66/*
67 * Only "raw" case insensitive strings. This is meant to be locale independent
68 * and only compare strings we know are safe for this.
69 *
70 * The function is capable of comparing a-z case insensitively.
71 *
72 * Result is 1 if text matches and 0 if not.
73 */
75/* --- public function --- */
76int curl_strequal(const char *s1, const char *s2)
77{
78 if(s1 && s2)
79 /* both pointers point to something then compare them */
80 return casecompare(s1, s2);
82 /* if both pointers are NULL then treat them as equal */
83 return NULL == s1 && NULL == s2;
84}
86/* --- public function --- */
87int curl_strnequal(const char *s1, const char *s2, size_t n)
88{
89 if(s1 && s2)
90 /* both pointers point to something then compare them */
91 return ncasecompare(s1, s2, n);
93 /* if both pointers are NULL then treat them as equal if max is non-zero */
94 return NULL == s1 && NULL == s2 && n;
95}
Diagnostics4 git calls · 196 ms
CallStatusSizeTime0196 ms
discover200152 B2 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200149 B · hit2 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=2 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=149 git.pkt.payload.max=78 git.ls_refs.count=2 git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=192 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=10 git.pkt.data=8 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=293470 git.pkt.payload.max=65516 git.sideband.band1.bytes=293354 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=87 git.pack.bytes=293354 git.pack.ofs_delta=0 git.pack.ref_delta=1 git.pack.chain.max=1 git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0 git.pack.full=86Open pack map
fetch2001.3 KiB192 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=1300 git.response.cache=MISS git.response.duration_ms=192 git.fetch.wants=a352fda70b246728660d097bcd4f2e9ae81b13de git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=1300 git.pkt.payload.max=1279 git.sideband.band1.bytes=1278 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
- Ref
- refs/heads/master
- Commit
- 31c911efe5652725e930f4d2e60c9060e5f6646d
- cf-ray
- a5e2d5523e9a689d
- Request
- 513e9199…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format