Skip to content

Commit 97a6515

Browse files
committed
add comments
1 parent 11764b1 commit 97a6515

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

c/socket/windows/client.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ typedef void Fun(char *);
1010
#define MAXLINE 100
1111
#define MAXRECV 0xfff
1212
13-
// get admin from url(String Slicing)
13+
// Get admin from url(String Slicing)
1414
void get_admin(const char *url, char *admin)
1515
{
1616
int start = 7;
@@ -37,7 +37,7 @@ void get_admin_ip(const char *url, char *ip)
3737
strcpy(ip, inet_ntoa(*iddr));
3838
}
3939
40-
// if url contians https, return 443, else return 80
40+
// If url contians https, return 443, else return 80
4141
int get_url_port(const char *url)
4242
{
4343
char *ret = strstr(url, "https");
@@ -82,7 +82,7 @@ void request(const char *sUrl, Fun fun)
8282
connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr));
8383
send(sockfd, send_msg, strlen(send_msg), 0);
8484

85-
//分段接收处理
85+
//Segmentation receiving treatment
8686
do
8787
{
8888
r = recv(sockfd, buf, MAXRECV, 0);

c/socket/windows/request.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <stdio.h>
33
#include <string.h>
44
#include <WinSock2.h>
5-
// #pragma comment(lib, "ws2_32.lib") //加载 ws2_32.dll
5+
// #pragma comment(lib, "ws2_32.lib") //load ws2_32.dll
66

77
typedef void Fun(char *, int);
88

@@ -24,6 +24,7 @@ const char *format_headers = (
2424
"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36 Edg/101.0.1210.47\r\n\r\n"
2525
);
2626

27+
// Get admin from url(String Slicing)
2728
void get_admin(const char * url, char *admin)
2829
{
2930
int start = 7;
@@ -47,6 +48,7 @@ void get_admin_ip(const char *url, char *ip)
4748
strcpy(ip, inet_ntoa(*iddr));
4849
}
4950

51+
// If url contians https, return 443, else return 80
5052
int get_url_port(const char * url)
5153
{
5254
int port;
@@ -185,7 +187,7 @@ void request(const char *sUrl, Fun *fun)
185187
sscanf(q, "%*s %s", data_type);
186188
check_type(sUrl, data_type, filename, get_file_name(header, filename));
187189

188-
// 打印 response
190+
// print response
189191
if (status != 200)
190192
printf("\n%s\n\n", header);
191193
fun(p, data_len);
@@ -228,6 +230,7 @@ void request(const char *sUrl, Fun *fun)
228230
return;
229231
}
230232

233+
// Example callback function
231234
void process_data(char * str, int len)
232235
{
233236
if (!dowm_flag)
@@ -240,6 +243,7 @@ void process_data(char * str, int len)
240243
}
241244
}
242245

246+
// Simply replace https with http
243247
void https_to_http(char **url)
244248
{
245249
if (url[1][4] == 's')

0 commit comments

Comments
 (0)