mirror of
https://github.com/fumiama/simple-kanban.git
synced 2026-06-30 08:00:27 +08:00
细节修正
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.0.0)
|
cmake_minimum_required(VERSION 2.6)
|
||||||
project(simple-kanban)
|
project(simple-kanban C)
|
||||||
|
|
||||||
include(TestBigEndian)
|
include(TestBigEndian)
|
||||||
test_big_endian(isBigEndian)
|
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 spb pthread)
|
||||||
target_link_libraries(simple-kanban-client pthread)
|
target_link_libraries(simple-kanban-client pthread)
|
||||||
target_link_libraries(cfgwriter spb)
|
target_link_libraries(cfgwriter spb)
|
||||||
|
|
||||||
|
INSTALL(TARGETS simple-kanban RUNTIME DESTINATION bin)
|
||||||
@@ -10,7 +10,7 @@ int main() {
|
|||||||
scanf("%s", cfg.pwd);
|
scanf("%s", cfg.pwd);
|
||||||
printf("Enter a set password: ");
|
printf("Enter a set password: ");
|
||||||
scanf("%s", cfg.sps);
|
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");
|
FILE* fp = fopen("cfg.sp", "wb");
|
||||||
if(fp) {
|
if(fp) {
|
||||||
set_pb(fp, types_len, sizeof(CONFIG), &cfg);
|
set_pb(fp, types_len, sizeof(CONFIG), &cfg);
|
||||||
|
|||||||
4
client.c
4
client.c
@@ -27,7 +27,7 @@ int recv_bin = 0;
|
|||||||
void getMessage(void *p) {
|
void getMessage(void *p) {
|
||||||
int c = 0;
|
int c = 0;
|
||||||
while((c = recv(sockfd, bufr, BUFSIZ, 0)) > 0) {
|
while((c = recv(sockfd, bufr, BUFSIZ, 0)) > 0) {
|
||||||
printf("Recv %d bytes: ", c);
|
printf("Recv %u bytes: ", c);
|
||||||
if(recv_bin) {
|
if(recv_bin) {
|
||||||
FILE* fp = fopen("dump.bin", "w+");
|
FILE* fp = fopen("dump.bin", "w+");
|
||||||
fwrite(bufr, c, 1, fp);
|
fwrite(bufr, c, 1, fp);
|
||||||
@@ -90,7 +90,7 @@ int main(int argc,char *argv[]) { //usage: ./client host port
|
|||||||
else puts("Send file error.");
|
else puts("Send file error.");
|
||||||
#endif
|
#endif
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
printf("Send count:%lld\n", len);
|
printf("Send count:%u\n", len);
|
||||||
} else puts("Open file error!");
|
} else puts("Open file error!");
|
||||||
} else {
|
} else {
|
||||||
send(sockfd, buf, strlen(buf), 0);
|
send(sockfd, buf, strlen(buf), 0);
|
||||||
|
|||||||
26
server.c
26
server.c
@@ -1,19 +1,19 @@
|
|||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/signal.h>
|
|
||||||
#include <sys/file.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <simple_protobuf.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <sys/file.h>
|
||||||
#include <pthread.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <simple_protobuf.h>
|
#include <unistd.h>
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#if !__APPLE__
|
#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;
|
re = sendfile(timer->accept_fd, fileno(fp), &len, file_size) >= 0;
|
||||||
if(!re) perror("Sendfile");
|
if(!re) perror("Sendfile");
|
||||||
#endif
|
#endif
|
||||||
printf("Send %lld bytes.\n", len);
|
printf("Send %uF bytes.\n", len);
|
||||||
close_file(fp);
|
close_file(fp);
|
||||||
timer->is_open = 0;
|
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) {
|
while(*(timer_pointer_of(p)->thread) && (timer_pointer_of(p)->numbytes = recv(accept_fd, buff, BUFSIZ, 0)) > 0) {
|
||||||
touch_timer(p);
|
touch_timer(p);
|
||||||
buff[timer_pointer_of(p)->numbytes] = 0;
|
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");
|
puts("Check buffer");
|
||||||
//处理部分粘连
|
//处理部分粘连
|
||||||
take_word(p, cfg->pwd);
|
take_word(p, cfg->pwd);
|
||||||
@@ -390,7 +390,7 @@ void handle_accept(void *p) {
|
|||||||
take_word(p, "dat");
|
take_word(p, "dat");
|
||||||
if(timer_pointer_of(p)->numbytes > 0) chkbuf(p);
|
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");
|
} else puts("Error allocating buffer");
|
||||||
*(timer_pointer_of(p)->thread) = 0;
|
*(timer_pointer_of(p)->thread) = 0;
|
||||||
kill_thread(timer_pointer_of(p));
|
kill_thread(timer_pointer_of(p));
|
||||||
|
|||||||
Reference in New Issue
Block a user