test/gs/ctest.html

changeset 80
0f1c55d2a90a
parent 75
c72b250866ab
equal deleted inserted replaced
79:07a3743ce6ac 80:0f1c55d2a90a
133 <a class="c2html-lineno" name="l80" href="#l80"> 80 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">0</span>; 133 <a class="c2html-lineno" name="l80" href="#l80"> 80 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">0</span>;
134 <a class="c2html-lineno" name="l81" href="#l81"> 81 </a>} 134 <a class="c2html-lineno" name="l81" href="#l81"> 81 </a>}
135 <a class="c2html-lineno" name="l82" href="#l82"> 82 </a> 135 <a class="c2html-lineno" name="l82" href="#l82"> 82 </a>
136 <a class="c2html-lineno" name="l83" href="#l83"> 83 </a><span class="c2html-keyword">int</span> util_strtoint(<span class="c2html-keyword">char</span> *str, <span class="c2html-type">int64_t</span> *value) { 136 <a class="c2html-lineno" name="l83" href="#l83"> 83 </a><span class="c2html-keyword">int</span> util_strtoint(<span class="c2html-keyword">char</span> *str, <span class="c2html-type">int64_t</span> *value) {
137 <a class="c2html-lineno" name="l84" href="#l84"> 84 </a> <span class="c2html-keyword">char</span> *end; 137 <a class="c2html-lineno" name="l84" href="#l84"> 84 </a> <span class="c2html-keyword">char</span> *end;
138 <a class="c2html-lineno" name="l85" href="#l85"> 85 </a> <span class="c2html-type">int64_t</span> val = strtoll(str, &end, <span class="c2html-macroconst">0</span>); 138 <a class="c2html-lineno" name="l85" href="#l85"> 85 </a> <span class="c2html-type">int64_t</span> val = strtoll(str, &amp;end, <span class="c2html-macroconst">0</span>);
139 <a class="c2html-lineno" name="l86" href="#l86"> 86 </a> <span class="c2html-keyword">if</span>(strlen(end) == <span class="c2html-macroconst">0</span>) { 139 <a class="c2html-lineno" name="l86" href="#l86"> 86 </a> <span class="c2html-keyword">if</span>(strlen(end) == <span class="c2html-macroconst">0</span>) {
140 <a class="c2html-lineno" name="l87" href="#l87"> 87 </a> *value = val; 140 <a class="c2html-lineno" name="l87" href="#l87"> 87 </a> *value = val;
141 <a class="c2html-lineno" name="l88" href="#l88"> 88 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">1</span>; 141 <a class="c2html-lineno" name="l88" href="#l88"> 88 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">1</span>;
142 <a class="c2html-lineno" name="l89" href="#l89"> 89 </a> } <span class="c2html-keyword">else</span> { 142 <a class="c2html-lineno" name="l89" href="#l89"> 89 </a> } <span class="c2html-keyword">else</span> {
143 <a class="c2html-lineno" name="l90" href="#l90"> 90 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">0</span>; 143 <a class="c2html-lineno" name="l90" href="#l90"> 90 </a> <span class="c2html-keyword">return</span> <span class="c2html-macroconst">0</span>;
147 <a class="c2html-lineno" name="l94" href="#l94"> 94 </a><span class="c2html-keyword">char</span>* util_url_path(<span class="c2html-keyword">char</span> *url) { 147 <a class="c2html-lineno" name="l94" href="#l94"> 94 </a><span class="c2html-keyword">char</span>* util_url_path(<span class="c2html-keyword">char</span> *url) {
148 <a class="c2html-lineno" name="l95" href="#l95"> 95 </a> <span class="c2html-keyword">char</span> *path = <span class="c2html-macroconst">NULL</span>; 148 <a class="c2html-lineno" name="l95" href="#l95"> 95 </a> <span class="c2html-keyword">char</span> *path = <span class="c2html-macroconst">NULL</span>;
149 <a class="c2html-lineno" name="l96" href="#l96"> 96 </a> <span class="c2html-type">size_t</span> len = strlen(url); 149 <a class="c2html-lineno" name="l96" href="#l96"> 96 </a> <span class="c2html-type">size_t</span> len = strlen(url);
150 <a class="c2html-lineno" name="l97" href="#l97"> 97 </a> <span class="c2html-keyword">int</span> slashcount = <span class="c2html-macroconst">0</span>; 150 <a class="c2html-lineno" name="l97" href="#l97"> 97 </a> <span class="c2html-keyword">int</span> slashcount = <span class="c2html-macroconst">0</span>;
151 <a class="c2html-lineno" name="l98" href="#l98"> 98 </a> <span class="c2html-keyword">int</span> slmax; 151 <a class="c2html-lineno" name="l98" href="#l98"> 98 </a> <span class="c2html-keyword">int</span> slmax;
152 <a class="c2html-lineno" name="l99" href="#l99"> 99 </a> <span class="c2html-keyword">if</span>(len &gt; <span class="c2html-macroconst">7</span> && !strncasecmp(url, <span class="c2html-string">"http://"</span>, <span class="c2html-macroconst">7</span>)) { 152 <a class="c2html-lineno" name="l99" href="#l99"> 99 </a> <span class="c2html-keyword">if</span>(len &gt; <span class="c2html-macroconst">7</span> &amp;&amp; !strncasecmp(url, <span class="c2html-string">"http://"</span>, <span class="c2html-macroconst">7</span>)) {
153 <a class="c2html-lineno" name="l100" href="#l100">100 </a> slmax = <span class="c2html-macroconst">3</span>; 153 <a class="c2html-lineno" name="l100" href="#l100">100 </a> slmax = <span class="c2html-macroconst">3</span>;
154 <a class="c2html-lineno" name="l101" href="#l101">101 </a> } <span class="c2html-keyword">else</span> <span class="c2html-keyword">if</span>(len &gt; <span class="c2html-macroconst">8</span> && !strncasecmp(url, <span class="c2html-string">"https://"</span>, <span class="c2html-macroconst">8</span>)) { 154 <a class="c2html-lineno" name="l101" href="#l101">101 </a> } <span class="c2html-keyword">else</span> <span class="c2html-keyword">if</span>(len &gt; <span class="c2html-macroconst">8</span> &amp;&amp; !strncasecmp(url, <span class="c2html-string">"https://"</span>, <span class="c2html-macroconst">8</span>)) {
155 <a class="c2html-lineno" name="l102" href="#l102">102 </a> slmax = <span class="c2html-macroconst">3</span>; 155 <a class="c2html-lineno" name="l102" href="#l102">102 </a> slmax = <span class="c2html-macroconst">3</span>;
156 <a class="c2html-lineno" name="l103" href="#l103">103 </a> } <span class="c2html-keyword">else</span> { 156 <a class="c2html-lineno" name="l103" href="#l103">103 </a> } <span class="c2html-keyword">else</span> {
157 <a class="c2html-lineno" name="l104" href="#l104">104 </a> slmax = <span class="c2html-macroconst">1</span>; 157 <a class="c2html-lineno" name="l104" href="#l104">104 </a> slmax = <span class="c2html-macroconst">1</span>;
158 <a class="c2html-lineno" name="l105" href="#l105">105 </a> } 158 <a class="c2html-lineno" name="l105" href="#l105">105 </a> }
159 <a class="c2html-lineno" name="l106" href="#l106">106 </a> <span class="c2html-keyword">char</span> c; 159 <a class="c2html-lineno" name="l106" href="#l106">106 </a> <span class="c2html-keyword">char</span> c;
263 <a class="c2html-lineno" name="l210" href="#l210">210 </a> <span class="c2html-comment">// remove trailing slash</span> 263 <a class="c2html-lineno" name="l210" href="#l210">210 </a> <span class="c2html-comment">// remove trailing slash</span>
264 <a class="c2html-lineno" name="l211" href="#l211">211 </a> ucx_buffer_seek(url, -<span class="c2html-macroconst">1</span>, <span class="c2html-macroconst">SEEK_CUR</span>); 264 <a class="c2html-lineno" name="l211" href="#l211">211 </a> ucx_buffer_seek(url, -<span class="c2html-macroconst">1</span>, <span class="c2html-macroconst">SEEK_CUR</span>);
265 <a class="c2html-lineno" name="l212" href="#l212">212 </a> 265 <a class="c2html-lineno" name="l212" href="#l212">212 </a>
266 <a class="c2html-lineno" name="l213" href="#l213">213 </a> <span class="c2html-type">sstr_t</span> p = sstr(path); 266 <a class="c2html-lineno" name="l213" href="#l213">213 </a> <span class="c2html-type">sstr_t</span> p = sstr(path);
267 <a class="c2html-lineno" name="l214" href="#l214">214 </a> <span class="c2html-type">ssize_t</span> ntk = <span class="c2html-macroconst">0</span>; 267 <a class="c2html-lineno" name="l214" href="#l214">214 </a> <span class="c2html-type">ssize_t</span> ntk = <span class="c2html-macroconst">0</span>;
268 <a class="c2html-lineno" name="l215" href="#l215">215 </a> <span class="c2html-type">sstr_t</span> *tks = sstrsplit(p, <span class="c2html-macroconst">S</span>(<span class="c2html-string">"/"</span>), &ntk); 268 <a class="c2html-lineno" name="l215" href="#l215">215 </a> <span class="c2html-type">sstr_t</span> *tks = sstrsplit(p, <span class="c2html-macroconst">S</span>(<span class="c2html-string">"/"</span>), &amp;ntk);
269 <a class="c2html-lineno" name="l216" href="#l216">216 </a> 269 <a class="c2html-lineno" name="l216" href="#l216">216 </a>
270 <a class="c2html-lineno" name="l217" href="#l217">217 </a> <span class="c2html-keyword">for</span>(<span class="c2html-keyword">int</span> i=<span class="c2html-macroconst">0</span>;i&lt;ntk;i++) { 270 <a class="c2html-lineno" name="l217" href="#l217">217 </a> <span class="c2html-keyword">for</span>(<span class="c2html-keyword">int</span> i=<span class="c2html-macroconst">0</span>;i&lt;ntk;i++) {
271 <a class="c2html-lineno" name="l218" href="#l218">218 </a> <span class="c2html-type">sstr_t</span> node = tks[i]; 271 <a class="c2html-lineno" name="l218" href="#l218">218 </a> <span class="c2html-type">sstr_t</span> node = tks[i];
272 <a class="c2html-lineno" name="l219" href="#l219">219 </a> <span class="c2html-keyword">if</span>(node.length &gt; <span class="c2html-macroconst">0</span>) { 272 <a class="c2html-lineno" name="l219" href="#l219">219 </a> <span class="c2html-keyword">if</span>(node.length &gt; <span class="c2html-macroconst">0</span>) {
273 <a class="c2html-lineno" name="l220" href="#l220">220 </a> <span class="c2html-keyword">char</span> *esc = curl_easy_escape(sn-&gt;handle, node.ptr, node.length); 273 <a class="c2html-lineno" name="l220" href="#l220">220 </a> <span class="c2html-keyword">char</span> *esc = curl_easy_escape(sn-&gt;handle, node.ptr, node.length);
313 <a class="c2html-lineno" name="l260" href="#l260">260 </a>} 313 <a class="c2html-lineno" name="l260" href="#l260">260 </a>}
314 <a class="c2html-lineno" name="l261" href="#l261">261 </a> 314 <a class="c2html-lineno" name="l261" href="#l261">261 </a>
315 <a class="c2html-lineno" name="l262" href="#l262">262 </a> 315 <a class="c2html-lineno" name="l262" href="#l262">262 </a>
316 <a class="c2html-lineno" name="l263" href="#l263">263 </a><span class="c2html-keyword">char</span>* util_base64decode(<span class="c2html-keyword">char</span> *in) { 316 <a class="c2html-lineno" name="l263" href="#l263">263 </a><span class="c2html-keyword">char</span>* util_base64decode(<span class="c2html-keyword">char</span> *in) {
317 <a class="c2html-lineno" name="l264" href="#l264">264 </a> <span class="c2html-keyword">int</span> len = <span class="c2html-macroconst">0</span>; 317 <a class="c2html-lineno" name="l264" href="#l264">264 </a> <span class="c2html-keyword">int</span> len = <span class="c2html-macroconst">0</span>;
318 <a class="c2html-lineno" name="l265" href="#l265">265 </a> <span class="c2html-keyword">return</span> util_base64decode_len(in, &len); 318 <a class="c2html-lineno" name="l265" href="#l265">265 </a> <span class="c2html-keyword">return</span> util_base64decode_len(in, &amp;len);
319 <a class="c2html-lineno" name="l266" href="#l266">266 </a>} 319 <a class="c2html-lineno" name="l266" href="#l266">266 </a>}
320 <a class="c2html-lineno" name="l267" href="#l267">267 </a> 320 <a class="c2html-lineno" name="l267" href="#l267">267 </a>
321 <a class="c2html-lineno" name="l268" href="#l268">268 </a><span class="c2html-keyword">char</span>* util_base64decode_len(<span class="c2html-keyword">char</span>* in, <span class="c2html-keyword">int</span> *outlen) { 321 <a class="c2html-lineno" name="l268" href="#l268">268 </a><span class="c2html-keyword">char</span>* util_base64decode_len(<span class="c2html-keyword">char</span>* in, <span class="c2html-keyword">int</span> *outlen) {
322 <a class="c2html-lineno" name="l269" href="#l269">269 </a> <span class="c2html-type">size_t</span> len = strlen(in); 322 <a class="c2html-lineno" name="l269" href="#l269">269 </a> <span class="c2html-type">size_t</span> len = strlen(in);
323 <a class="c2html-lineno" name="l270" href="#l270">270 </a> <span class="c2html-keyword">char</span> *out = calloc(<span class="c2html-macroconst">1</span>, len); 323 <a class="c2html-lineno" name="l270" href="#l270">270 </a> <span class="c2html-keyword">char</span> *out = calloc(<span class="c2html-macroconst">1</span>, len);
343 <a class="c2html-lineno" name="l290" href="#l290">290 </a> 343 <a class="c2html-lineno" name="l290" href="#l290">290 </a>
344 <a class="c2html-lineno" name="l291" href="#l291">291 </a> e = BIO_push(e, b); 344 <a class="c2html-lineno" name="l291" href="#l291">291 </a> e = BIO_push(e, b);
345 <a class="c2html-lineno" name="l292" href="#l292">292 </a> BIO_write(e, in, len); 345 <a class="c2html-lineno" name="l292" href="#l292">292 </a> BIO_write(e, in, len);
346 <a class="c2html-lineno" name="l293" href="#l293">293 </a> BIO_flush(e); 346 <a class="c2html-lineno" name="l293" href="#l293">293 </a> BIO_flush(e);
347 <a class="c2html-lineno" name="l294" href="#l294">294 </a> 347 <a class="c2html-lineno" name="l294" href="#l294">294 </a>
348 <a class="c2html-lineno" name="l295" href="#l295">295 </a> BIO_get_mem_ptr(e, &mem); 348 <a class="c2html-lineno" name="l295" href="#l295">295 </a> BIO_get_mem_ptr(e, &amp;mem);
349 <a class="c2html-lineno" name="l296" href="#l296">296 </a> <span class="c2html-keyword">char</span> *out = malloc(mem-&gt;length); 349 <a class="c2html-lineno" name="l296" href="#l296">296 </a> <span class="c2html-keyword">char</span> *out = malloc(mem-&gt;length);
350 <a class="c2html-lineno" name="l297" href="#l297">297 </a> memcpy(out, mem-&gt;data, mem-&gt;length -<span class="c2html-macroconst">1</span>); 350 <a class="c2html-lineno" name="l297" href="#l297">297 </a> memcpy(out, mem-&gt;data, mem-&gt;length -<span class="c2html-macroconst">1</span>);
351 <a class="c2html-lineno" name="l298" href="#l298">298 </a> out[mem-&gt;length - <span class="c2html-macroconst">1</span>] = <span class="c2html-string">'\0'</span>; 351 <a class="c2html-lineno" name="l298" href="#l298">298 </a> out[mem-&gt;length - <span class="c2html-macroconst">1</span>] = <span class="c2html-string">'\0'</span>;
352 <a class="c2html-lineno" name="l299" href="#l299">299 </a> 352 <a class="c2html-lineno" name="l299" href="#l299">299 </a>
353 <a class="c2html-lineno" name="l300" href="#l300">300 </a> BIO_free_all(e); 353 <a class="c2html-lineno" name="l300" href="#l300">300 </a> BIO_free_all(e);

mercurial