Skip to content

编译错误 修复 ,升级libuv 版本 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
编译错误 修复 ,升级libuv 版本
  • Loading branch information
root authored and root committed Jul 29, 2024
commit e404541aaa9203852c984b5e75d485718ad9dfc6
22 changes: 11 additions & 11 deletions Main.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ char on_request(void* data, uv_stream_t* client, tw_peerAddr* pa, tw_reqHeads* h
else if (cmpi(heads->path, "/gettype")){
//动态返回内容
char* str="{\"type\":\"UTF-8 string\"}";
tw_send_200_OK(client, nullptr, "application/json", str, strlen(str), 0);
tw_send_200_OK(client, NULL, "application/json", str, strlen(str), 0);
return 1;//已处理请求
}
return 0;//返回0表示未处理,TinyWeb 继续处理
Expand Down Expand Up @@ -165,19 +165,19 @@ char on_socket_data(void* data, uv_stream_t* client, tw_peerAddr* pa, membuf_t*

char on_close(void* data, uv_stream_t* client, tw_peerAddr* pa)
{
printf("closed: sk=%zd [%s:%d] from:%s:%d cli:%d\n", pa->sk, pa->ip, pa->port, pa->fip, pa->fport, client->loop->active_tcp_streams);
printf("closed: sk=%zd [%s:%d] from:%s:%d cli:%d\n", pa->sk, pa->ip, pa->port, pa->fip, pa->fport, client->loop->active_handles);
return 0;
}

char on_error(void* data, uv_stream_t* client, tw_peerAddr* pa, int errcode, char* errstr)
{
printf("error: sk=%zd [%s:%d] from:%s:%d cli:%d %s\n", pa->sk, pa->ip, pa->port, pa->fip, pa->fport, client->loop->active_tcp_streams,errstr);
printf("error: sk=%zd [%s:%d] from:%s:%d cli:%d %s\n", pa->sk, pa->ip, pa->port, pa->fip, pa->fport, client->loop->active_handles, errstr);
return 0;
}

char on_connect(void* data, uv_stream_t* client, tw_peerAddr* pa)
{
printf("connected: sk=%zd [%s:%d] from:%s:%d cli:%d\n",pa->sk,pa->ip,pa->port,pa->fip,pa->fport, client->loop->active_tcp_streams);
printf("connected: sk=%zd [%s:%d] from:%s:%d cli:%d\n",pa->sk,pa->ip,pa->port,pa->fip,pa->fport, client->loop->active_handles);
return 0;
}
const char* help =
Expand Down Expand Up @@ -225,13 +225,13 @@ int main(int argc, char** argv)
char cmd[11];
if (argc < 5) { //cmd: "", "dir", "port", "-d dir", "-p port"
for (i = 1; i < argc;) {
if (strcmpi(argv[i], "-d") == 0) {
if (strcmp(argv[i], "-d") == 0) {
if (++i < argc)
dir = argv[i++];
else
return printf("need dir\n%s", help), 0;
}
if (i < argc && strcmpi(argv[i], "-p") == 0) {
if (i < argc && strcmp(argv[i], "-p") == 0) {
if ( ++i < argc)
port = atoi(argv[i++]);
else
Expand All @@ -252,15 +252,15 @@ int main(int argc, char** argv)
{
port = 0;
dir = NULL;
if (strcmpi(argv[i], "-d") == 0 && ++i < argc)
if (strcmp(argv[i], "-d") == 0 && ++i < argc)
dir = argv[i++];
else if (strcmpi(argv[i], "-p") == 0 && ++i < argc)
else if (strcmp(argv[i], "-p") == 0 && ++i < argc)
port = atoi(argv[i++]);
else
return printf(help), 0;
if (strcmpi(argv[i], "-d") == 0 && ++i < argc)
if (strcmp(argv[i], "-d") == 0 && ++i < argc)
dir = argv[i++];
else if (strcmpi(argv[i], "-p") == 0 && ++i < argc)
else if (strcmp(argv[i], "-p") == 0 && ++i < argc)
port = atoi(argv[i++]);
else
return printf(help), 0;
Expand All @@ -273,7 +273,7 @@ int main(int argc, char** argv)
//
while (1) {
fgets(cmd, 10, stdin);//the 'gets' function is dangerous and should not be used
if (strcmpi(cmd, "Q\n") == 0 || strcmpi(cmd, "exit\n") == 0)
if (strcmp(cmd, "Q\n") == 0 || strcmp(cmd, "exit\n") == 0)
break;
}
//tinyweb_stop(loop);
Expand Down
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ PWD=$(shell pwd)

INCS=
LIBEDIT_DIR=

DEBUG=-g -ggdb -gstabs+
BASE_FLAGS=$(INCS) $(DEBUG) $(LIBEDIT_DIR) -lpthread #-fPIC
BASE_FLAGS=-I$(INCS) $(DEBUG) -L$(LIBEDIT_DIR) -lpthread #-fPIC
LDFLAGS=-L.

CC_CFLAGS=$(BASE_FLAGS) #-Wl,-rpath=/usr/local/lib/
Expand All @@ -21,16 +22,15 @@ CXX=g++

all: tinyweb


tinyweb: tools.o tinyweb.o Main.o libuv.a
$(CC) $(CC_CFLAGS) $(CFLAGS) -o tinyweb Main.o tinyweb.o tools.o -lrt libuv.a
tinyweb: Main.o tinyweb.a
$(CC) $(CC_CFLAGS) $(CFLAGS) -o tinyweb Main.o tinyweb.a -lrt -l:libuv.a
@echo make tinyweb done.

tinyweb.a: tools.o tinyweb.o
ar crv tinyweb.a tools.o tinyweb.o


libuv.a:
cp /usr/local/lib/libuv.a ./

tinyweb.a: tools.o tinyweb.o
ar crv $@ $^

%.o: %.c $(HEADERS)
$(CC) $(CC_CFLAGS) $(CFLAGS) -c $< -o $@
Expand Down