Wandbox
SettingsLog
SettingsLog
Language
GitHubLogin
Ran/Viewed Log

Viewed less than a minute ago

KYK8GygDOgxL4fvi

C gcc 12.1.0

Created at 1 minute ago

Created by anonymous

Author

anonymous

1 minute ago

Language

C

Compiler

gcc 12.1.0

Options
Warnings
Optimization
C99
no pedantic
セオライド・テクノロジー㈱株式会社フィックスターズ
Siv3D

Author

anonymous

1 minute ago

›
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char url[] = "https://objects.githubusercontent.com/github-production-release-asset-2e65be/21611723/f7cfd480-a7ea-11ea-852c-52df94ee4644?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20220728%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220728T104250Z&X-Amz-Expires=300&X-Amz-Signature=7dbec7d58625f02f8b4dba25f74a9b3cc688184704c228f256a6a855ab41f19c&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=21611723&response-content-disposition=attachment%3B%20filename%3DQuasar.v1.4.0.zip&response-content-type=application%2Foctet-stream";

void parser(char * result, char * host, char * endpoint)
{
int i=0,j=0;
int size = strlen(result);
if (strstr(result , "https://"))
{
for (i=8; i < size; i++)
{
if (result[i] == '/') break;
host[j] = result[i];
j++;
}
host[j] = '\0';
j=0;
while ( i < strlen(result))
{
endpoint[j] = result[i];
i++,j++;
}
endpoint[j] = '\0';
}
}

int main(void) {
char host[1024], endpoint[1024];
parser(url, host, endpoint);

char * request = (char *)malloc(8192);
sprintf(request , "%s %s HTTP/1.1\n%s\r\n\r\n%s", "GET", endpoint, "","");

printf("host: \"%s\"\n", host);
printf("endpoint: \"%s\"\n", endpoint);
puts("request:");
fputs(request, stdout);
return 0;
}


$ gcc prog.c -Wall -Wextra -std=gnu11
prog.c: In function 'parser':
prog.c:21:19: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         while ( i < strlen(result))
      |                   ^
host: "objects.githubusercontent.com"
endpoint: "/github-production-release-asset-2e65be/21611723/f7cfd480-a7ea-11ea-852c-52df94ee4644?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20220728%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220728T104250Z&X-Amz-Expires=300&X-Amz-Signature=7dbec7d58625f02f8b4dba25f74a9b3cc688184704c228f256a6a855ab41f19c&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=21611723&response-content-disposition=attachment%3B%20filename%3DQuasar.v1.4.0.zip&response-content-type=application%2Foctet-stream"
request:
GET /github-production-release-asset-2e65be/21611723/f7cfd480-a7ea-11ea-852c-52df94ee4644?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20220728%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220728T104250Z&X-Amz-Expires=300&X-Amz-Signature=7dbec7d58625f02f8b4dba25f74a9b3cc688184704c228f256a6a855ab41f19c&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=21611723&response-content-disposition=attachment%3B%20filename%3DQuasar.v1.4.0.zip&response-content-type=application%2Foctet-stream HTTP/1.1


Exit Code:
0
セオライド・テクノロジー㈱株式会社フィックスターズ
Siv3D