Created
September 25, 2019 09:11
-
-
Save s4553711/0af4456cf9a68c9d1c56d015145a2b9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <zlib.h> | |
#include <time.h> | |
#include <stdio.h> | |
#include <stdbool.h> | |
#include <sys/uio.h> | |
#include <fcntl.h> | |
#include <unistd.h> | |
#include <inttypes.h> | |
#include "kseq.h" | |
#include "kstring.h" | |
int main(int argc, char *argv[]) { | |
char buf[1000] = {0}; | |
char *p = buf; | |
int p1, f; | |
struct iovec iov; | |
f = open(argv[1], O_RDONLY); | |
p1 = open("f1", O_WRONLY); | |
while(read(f, buf, sizeof(buf)) > 0) { | |
//printf("\n1>%c\n", p); | |
//printf("> %c\n", p[0]); | |
printf("%.1000s", p); | |
//strcat(buf, "\n"); | |
//write(p1, buf, strlen(buf)); | |
int len = strlen(buf); | |
int ret; | |
printf("\nDEBUG> total %d\n", len); | |
while(len) { | |
iov.iov_base = buf; | |
iov.iov_len = strlen(buf); | |
ret =vmsplice(p1, &iov, 1, 8); | |
printf("\nDEBUG> Send %d bytes\n", ret); | |
len -= ret; | |
iov.iov_len -= ret; | |
iov.iov_base += ret; | |
//printf("\nDEBUG> Send %d\n", ret); | |
} | |
memset(p, 0, 100); | |
} | |
close(p1); | |
close(f); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment