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 ***************************************************************************/
26/* CL interface program to curl cli tool. */
28#include <stdio.h>
29#include <stdlib.h>
31#include <milib.h>
32#include <miptrnam.h>
33#include <mih/callpgmv.h>
35#ifndef CURLPGM
36#define CURLPGM "CURL"
37#endif
39/* Variable-length string, with 16-bit length. */
40struct vary2 {
41 short len;
42 char string[5000];
43};
45/* Arguments from CL command. */
46struct arguments {
47 char *pgm; /* Program name. */
48 struct vary2 *cmdargs; /* Command line arguments. */
49};
51static int is_ifs(char c)
52{
53 return c == ' ' || c == '\t' || c == '\r' || c == '\n';
54}
56static int parse_command_line(const char *cmdargs, size_t len, size_t *argc,
57 char **argv, size_t *argsize, char *argbuf)
58{
59 const char *endline = cmdargs + len;
60 char quote = '\0';
61 int inarg = 0;
63 *argc = 0;
64 *argsize = 0;
66 while(cmdargs < endline) {
67 char c = *cmdargs++;
69 if(!inarg) {
70 /* Skip argument separator. */
71 if(is_ifs(c))
72 continue;
74 /* Start a new argument. */
75 ++*argc;
76 if(argv)
77 *argv++ = argbuf;
78 inarg = 1;
79 }
81 /* Check for quoting end. */
82 if(quote && quote == c) {
83 quote = '\0';
84 continue;
85 }
87 /* Check for backslash-escaping. */
88 if(quote != '\'' && c == '\\') {
89 if(cmdargs >= endline) {
90 fputs("Trailing backslash in command\n", stderr);
91 return -1;
92 }
93 c = *cmdargs++;
94 }
95 else if(!quote && is_ifs(c)) { /* Check for end of argument. */
96 inarg = 0;
97 c = '\0'; /* Will store a string terminator. */
98 }
100 /* Store argument character and count it. */
101 if(argbuf)
102 *argbuf++ = c;
103 ++*argsize;
104 }
106 if(quote) {
107 /* !checksrc! disable BANNEDFUNC 1 */
108 fprintf(stderr, "Unterminated quote: %c\n", quote);
109 return -1;
110 }
112 /* Terminate last argument. */
113 if(inarg) {
114 if(argbuf)
115 *argbuf = '\0';
116 ++*argsize;
117 }
119 /* Terminate argument list. */
120 if(argv)
121 *argv = NULL;
123 return 0;
124}
126int main(int argsc, struct arguments *args)
127{
128 size_t argc;
129 char **argv;
130 size_t argsize;
131 int i;
132 int exitcode;
133 char library[11];
135 /* Extract current program library name. */
136 for(i = 0; i < 10; i++) {
137 char c = args->pgm[i];
139 if(!c || c == '/')
140 break;
142 library[i] = c;
143 }
144 library[i] = '\0';
146 /* Measure arguments size. */
147 exitcode = parse_command_line(args->cmdargs->string, args->cmdargs->len,
148 &argc, NULL, &argsize, NULL);
150 if(!exitcode) {
151 /* Allocate space for parsed arguments. */
152 argv = malloc((argc + 1) * sizeof(*argv) + argsize);
153 if(!argv) {
154 fputs("Memory allocation error\n", stderr);
155 exitcode = -2;
156 }
157 else {
158 _SYSPTR pgmptr = rslvsp(WLI_PGM, (char *)CURLPGM, library, _AUTH_NONE);
159 _LU_Work_Area_T *luwrka = (_LU_Work_Area_T *)_LUWRKA();
161 parse_command_line(args->cmdargs->string, args->cmdargs->len, &argc,
162 argv, &argsize, (char *)(argv + argc + 1));
164 /* Call program. */
165 _CALLPGMV((void *)&pgmptr, argv, argc);
166 exitcode = luwrka->LU_RC;
168 free(argv);
169 }
170 }
172 return exitcode;
173}
Diagnostics4 git calls · 356 ms
CallStatusSizeTime0356 ms
discover200152 B3 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 · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=350 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=3 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.8 KiB350 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=1806 git.response.cache=MISS git.response.duration_ms=350 git.fetch.wants=76bf873b296a536ce1be3611dd9137eb481683c9 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=1806 git.pkt.payload.max=1785 git.sideband.band1.bytes=1784 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
- a5e30a203a77ee28
- Request
- efa266fd…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format