From 226d690c20695c709b3ede151f3b758b4d5857ea Mon Sep 17 00:00:00 2001 From: fumiama Date: Wed, 19 May 2021 13:16:38 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=86=E8=8A=82=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 6 ++++-- cfgwriter.c | 2 +- client.c | 4 ++-- server.c | 26 +++++++++++++------------- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2eea6eb..c8d87f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required(VERSION 3.0.0) -project(simple-kanban) +cmake_minimum_required(VERSION 2.6) +project(simple-kanban C) include(TestBigEndian) test_big_endian(isBigEndian) @@ -19,3 +19,5 @@ add_executable(cfgwriter cfgwriter.c) target_link_libraries(simple-kanban spb pthread) target_link_libraries(simple-kanban-client pthread) target_link_libraries(cfgwriter spb) + +INSTALL(TARGETS simple-kanban RUNTIME DESTINATION bin) \ No newline at end of file diff --git a/cfgwriter.c b/cfgwriter.c index bcbb484..c37121f 100644 --- a/cfgwriter.c +++ b/cfgwriter.c @@ -10,7 +10,7 @@ int main() { scanf("%s", cfg.pwd); printf("Enter a set password: "); scanf("%s", cfg.sps); - uint64_t* types_len = align_struct(sizeof(CONFIG), 2, &cfg.pwd, &cfg.sps); + uint32_t* types_len = align_struct(sizeof(CONFIG), 2, &cfg.pwd, &cfg.sps); FILE* fp = fopen("cfg.sp", "wb"); if(fp) { set_pb(fp, types_len, sizeof(CONFIG), &cfg); diff --git a/client.c b/client.c index f4bf24c..1789691 100644 --- a/client.c +++ b/client.c @@ -27,7 +27,7 @@ int recv_bin = 0; void getMessage(void *p) { int c = 0; while((c = recv(sockfd, bufr, BUFSIZ, 0)) > 0) { - printf("Recv %d bytes: ", c); + printf("Recv %u bytes: ", c); if(recv_bin) { FILE* fp = fopen("dump.bin", "w+"); fwrite(bufr, c, 1, fp); @@ -90,7 +90,7 @@ int main(int argc,char *argv[]) { //usage: ./client host port else puts("Send file error."); #endif fclose(fp); - printf("Send count:%lld\n", len); + printf("Send count:%u\n", len); } else puts("Open file error!"); } else { send(sockfd, buf, strlen(buf), 0); diff --git a/server.c b/server.c index f35253e..a8909c7 100644 --- a/server.c +++ b/server.c @@ -1,19 +1,19 @@ -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include #include #include #include -#include -#include +#include +#include +#include +#include +#include #include -#include +#include #include "config.h" #if !__APPLE__ @@ -160,7 +160,7 @@ int send_all(char* file_path, THREADTIMER *timer) { re = sendfile(timer->accept_fd, fileno(fp), &len, file_size) >= 0; if(!re) perror("Sendfile"); #endif - printf("Send %lld bytes.\n", len); + printf("Send %uF bytes.\n", len); close_file(fp); timer->is_open = 0; } @@ -378,7 +378,7 @@ void handle_accept(void *p) { while(*(timer_pointer_of(p)->thread) && (timer_pointer_of(p)->numbytes = recv(accept_fd, buff, BUFSIZ, 0)) > 0) { touch_timer(p); buff[timer_pointer_of(p)->numbytes] = 0; - printf("Get %zd bytes: %s\n", timer_pointer_of(p)->numbytes, buff); + printf("Get %u bytes: %s\n", timer_pointer_of(p)->numbytes, buff); puts("Check buffer"); //处理部分粘连 take_word(p, cfg->pwd); @@ -390,7 +390,7 @@ void handle_accept(void *p) { take_word(p, "dat"); if(timer_pointer_of(p)->numbytes > 0) chkbuf(p); } - printf("Break: recv %zd bytes\n", timer_pointer_of(p)->numbytes); + printf("Break: recv %u bytes\n", timer_pointer_of(p)->numbytes); } else puts("Error allocating buffer"); *(timer_pointer_of(p)->thread) = 0; kill_thread(timer_pointer_of(p));