/*
- * Copyright (C) 2015 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
+ * Copyright (C) 2015-2016 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <errno.h>
#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+
int set_llong(char *str, long long *val)
{
char *end = NULL;
return -errno;
return 0;
}
+
+int dumpfile(int fd, char *filename)
+{
+ int inp;
+ char buffer[256];
+ int r;
+ inp = open(filename, O_RDONLY);
+ if (inp < 0)
+ return -errno;
+ while ((r = read(inp, buffer, sizeof(buffer))) > 0) {
+ write(fd, buffer, r);
+ }
+ close(inp);
+ return r;
+}