mirror of
https://github.com/fumiama/simple-kanban.git
synced 2026-06-24 04:28:14 +08:00
fix data print
This commit is contained in:
20
server.c
20
server.c
@@ -478,19 +478,25 @@ static int send_all(char* file_path, threadtimer_t *timer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int send_data(int accept_fd, char *data, size_t length) {
|
static int send_data(int accept_fd, char *data, size_t length) {
|
||||||
|
char buf[128];
|
||||||
|
if(length == 0) {
|
||||||
|
puts("Send data error: zero length");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if(!~send(accept_fd, data, length, MSG_DONTWAIT)) {
|
if(!~send(accept_fd, data, length, MSG_DONTWAIT)) {
|
||||||
puts("Send data error");
|
puts("Send data error");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
printf("Send data: ");
|
printf("Send data: ");
|
||||||
if(length > 128) {
|
if(length > 128) {
|
||||||
data[124] = '.';
|
memcpy(buf, data, 124);
|
||||||
data[125] = '.';
|
buf[124] = '.';
|
||||||
data[126] = '.';
|
buf[125] = '.';
|
||||||
data[127] = 0;
|
buf[126] = '.';
|
||||||
}
|
buf[127] = 0;
|
||||||
if(data[length-1]) data[length-1] = 0;
|
} else memcpy(buf, data, length);
|
||||||
puts(data);
|
if(buf[length-1]) buf[length-1] = 0;
|
||||||
|
puts(buf);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user