Skip to content

Instantly share code, notes, and snippets.

@s4553711
Created September 25, 2019 09:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s4553711/0af4456cf9a68c9d1c56d015145a2b9d to your computer and use it in GitHub Desktop.
Save s4553711/0af4456cf9a68c9d1c56d015145a2b9d to your computer and use it in GitHub Desktop.
#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