summaryrefslogtreecommitdiff
path: root/rfile.c
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeffrey.armstrong@approximatrix.com>2014-01-03 10:04:01 -0500
committerJeffrey Armstrong <jeffrey.armstrong@approximatrix.com>2014-01-03 10:04:01 -0500
commit50ff0e53d94c60860e768100f549e4dfe9110096 (patch)
tree65175313745a4aad498d781092dd89f8fbd47276 /rfile.c
parent2719471cb97c721e929c98c6bad40a381269295e (diff)
downloadprism-50ff0e53d94c60860e768100f549e4dfe9110096.tar.gz
prism-50ff0e53d94c60860e768100f549e4dfe9110096.zip
Files can now be committed to version control. Each version is stored in gzip'd form. Fix to MD5 calculation.
Diffstat (limited to 'rfile.c')
-rw-r--r--rfile.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/rfile.c b/rfile.c
index 497d383..11511a3 100644
--- a/rfile.c
+++ b/rfile.c
@@ -5,6 +5,7 @@
#include "prism.h"
#include "md5.h"
#include "rfile.h"
+#include "compress.h"
static const char hex_str[]= "0123456789abcdef";
@@ -23,8 +24,8 @@ int i;
return PRET_READERROR;
MD5_Init(&hb);
- while(fgets(buf, 15, fp)) {
- MD5_Update(&hb, buf, strlen(buf));
+ while((i = fread(buf, sizeof(char), 15, fp)) > 0) {
+ MD5_Update(&hb, buf, i);
}
fclose(fp);
@@ -37,3 +38,19 @@ int i;
return PRET_OK;
}
+
+int compress_file(const char *filename, int id, int revision)
+{
+char *newfile;
+
+ /* Arbitrary size... */
+ newfile = (char *)malloc(128*sizeof(char));
+ if(newfile == NULL)
+ return PRET_ERROR;
+ snprintf(newfile, 128, "%s%s%x.%x", PDB_DIR, DIR_SEP, id, revision);
+
+ if(file_compress(filename, newfile) >= 0)
+ return PRET_OK;
+
+ return PRET_GZFAILED;
+}